RE: [Java-gnome-developer] How can I access data/object in event callbacks?
Brought to you by:
afcowie
|
From: Jeffrey M. <Jef...@Br...> - 2001-11-21 13:44:29
|
> > Using Glade I can associate data with signals. My question is: How can > I access this data in my callbacks? I could this when building a > calculator for example, where the callback of all buttons representing > digits could be the same. The example that you sent contains the answer. If you look at your callback methods the parameter that is passed is the data from glade. For example, in the method mapped to the click event for button one: public void on_digitButton1_clicked(Object button) If you put the value "1" in the "Data" field in the signal tab in glade then the Object button actually is the value 1. If you execute System.out.println(button.toString()) It will print "1". What you can do is map all of your numeric buttons to the same callback that knows how to deal with numbers passing the value that is the label. Map your operator buttons to a signal callback that understands how to deal with operators. -Jeff |