3

I'm trying to create a program with Gtk2Hs and Haskell and I wonder if it is possible to create a new signal with Gtk.

For example I created a hBox containing a button and a text entry. This component can be added at differents places in the window and I would like to trigger some action when the button is pressed or when the entry is edited.

Is it possible to create and force the widget (the hBox?) to emit a custom my_own_signal with something like :

onbuttonPressed button $ do emit my_own_signal
onEntryActivate entry $ do emit my_own_signal

which could be captured by making a

on hbox my_own_signal $ do somethings

or

on my_widget my_own_signal $ do somethings

This way I could have a "global" signal for my widget/hbox

I'm using GHC 7.4.1 and Gtk2Hs 0.12.3

Cactus
  • 27,075
  • 9
  • 69
  • 149
JeanJouX
  • 2,555
  • 1
  • 25
  • 37
  • Why do you want to create your own signal? Couldn't you just connect handlers to the signals that are already provided? – andlabs Jan 19 '15 at 19:33
  • Looking at the docs, [Signal](http://hackage.haskell.org/package/glib-0.13.0.7/docs/System-Glib-Signals.html#t:Signal) has its constructor exported... can you formulate your "attaching a new callback to the signal" operation as `Bool -> object -> handler -> IO (ConnectId object)`? (the `Bool` is for before/after). – Cactus Jan 20 '15 at 02:06

0 Answers0