title: Gtk2hs: automatically select all text on mouse focus
body: <p>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?</p>
  
  <pre><code>import Graphics.UI.Gtk
  
  main :: IO ()
  main = do
    initGUI
  
    vbox   &lt;- vBoxNew False 4
    window &lt;- windowNew
    set window [ containerBorderWidth := 8,
                 containerChild := vbox ]
  
    mkEntry "Entry 1" vbox
    mkEntry "Entry 2" vbox
  
    onDestroy window mainQuit
    widgetShowAll window
    mainGUI
  
  
  mkEntry :: String -&gt; VBox -&gt; IO Entry
  mkEntry txt vbox = do
    entry &lt;- 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
  </code></pre>