I need entry controls to automatically select-all text when they receive focus. If you run the code and press tab to switch focus between the two controls, all of the text in the control is automatically selected. I need the same behavior when using the mouse to select the other control. My question is: what GTK event is signaled when an entry control is clicked with the mouse?
import Graphics.UI.Gtk
main :: IO ()
main = do
initGUI
vbox <- vBoxNew False 4
window <- windowNew
set window [ containerBorderWidth := 8,
containerChild := vbox ]
mkEntry "Entry 1" vbox
mkEntry "Entry 2" vbox
onDestroy window mainQuit
widgetShowAll window
mainGUI
mkEntry :: String -> VBox -> IO Entry
mkEntry txt vbox = do
entry <- entryNew
entrySetText entry txt
boxPackStart vbox entry PackNatural 0
-- selects all text when tabbing into the control
entry `on` entryActivate $ do editableSelectRegion entry 0 (-1)
return entry