Pregunta

Estoy escribiendo mi primera aplicación gtk2hs + glade, y estoy usando una vista de texto para mostrar la salida del programa. En lugar de desplazarse, lo que se suponía que era el comportamiento predeterminado, la vista de texto se hace más grande cada vez que restablezco el texto y hace que mis botones debajo sean más pequeños hasta que desaparezcan, pero las barras de desplazamiento nunca aparecen y nunca se desplaza. ¿Se supone que debo hacer algo especial para que se desplace? Aquí está la función principal que estoy usando en este momento, perdona el código sucio, tengo la intención de limpiar la casa más tarde. :)

main :: FilePath -> IO ()
main gladepath = do
initGUI
-- Create inital game state
st <- newIORef (State "" "" "" 0 0 0)
-- Get handles to all needed widgets from Glade file
Just xml <- xmlNew gladepath
mw     <- xmlGetWidget xml castToWindow "mainWindow"
sw     <- xmlGetWidget xml castToWindow "window2"
mb     <- xmlGetWidget xml castToButton "fireButton"
ng     <- xmlGetWidget xml castToButton "nbutton"
mv     <- xmlGetWidget xml castToTextView "textview1"
but    <- xmlGetWidget xml castToButton "button1"
ab     <- xmlGetWidget xml castToAboutDialog "aboutdialog1"
menu   <- xmlGetWidget xml castToMenuItem "menuitem3"
about  <- xmlGetWidget xml castToMenuItem "imagemenuitem10"
quitb  <- xmlGetWidget xml castToMenuItem "menuitem3"
p1name <- xmlGetWidget xml castToEntry "entry1"
p2name <- xmlGetWidget xml castToEntry "entry2"
spin   <- xmlGetWidget xml castToSpinButton "spinbutton1"
sett   <- xmlGetWidget xml castToMenuItem "menuitem2"
p1lab  <- xmlGetWidget xml castToLabel "label4"
p2lab  <- xmlGetWidget xml castToLabel "label5"
cylab  <- xmlGetWidget xml castToLabel "label6"
-- Handle events and such
buff <- textViewGetBuffer mv
onActivateLeaf quitb mainQuit
onResponse ab $ \resp -> 
   case resp of
      ResponseClose -> widgetHide ab
      _             -> widgetHide ab
onActivateLeaf about $ widgetShow ab
onActivateLeaf sett  $ widgetShowAll sw
onDelete sw $ \_ -> widgetHide sw >> return True
onClicked but $ 
          initalize sw p1name p2name spin st p1lab p2lab cylab buff
onClicked ng $ widgetShowAll sw
onDelete ab $ \_ -> widgetHide ab >> return True
onClicked mb $ fireButton st sw buff cylab
onActivateLeaf menu $ widgetDestroy mw
onDestroy mw mainQuit
widgetShowAll mw
mainGUI

Si necesita algo más, solicítelo en un comentario. No estoy seguro de si necesito proporcionar algo más.

El archivo glade es demasiado grande para mostrar aquí, pero lo pegué aquí en caso de que alguien lo necesite: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=6310#a6310

¿Fue útil?

Solución

Me las arreglé para resolver mi propio problema después de hablar con Axel en la lista de correo de gtk2hs.

Las vistas de texto están diseñadas para que puedan ser una sola línea de texto o una vista de texto multilínea con barras de desplazamiento. Si desea capacidades de desplazamiento, debe colocar TextView en una ventana desplazada. Resolví mi problema colocando mi TextView en una ventana desplazada, ahora funciona perfectamente.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top