[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AW: [paragui-users] Button-ID within a WidgetList???
From: |
Alexander Pipelka |
Subject: |
Re: AW: [paragui-users] Button-ID within a WidgetList??? |
Date: |
26 Jun 2002 11:30:12 +0200 |
You have to set the callback for every button.
It's perfectly legal to connect any number of buttons to *one* callback
function.
The callback function looks like this:
bool callback(int id, PG_Widget* widget, unsigned long data, void
*clientdata)
You can use the PARAGUI_CALLBACK macro to simplify the callback
definition.
Consider this:
class MyClass : public PG_EventObject {
PARAGUI_CALLBACK(handler) {
switch(id) {
case 1:
.
case 2:
.
}
return true;
}
}
MyClass obj;
myButton1.SetEventObject(MSG_BUTTONCLICK, &obj,
(MSG_CALLBACK_OBJ)&MyClass::handler);
myButton2.SetEventObject(MSG_BUTTONCLICK, &obj,
(MSG_CALLBACK_OBJ)&MyClass::handler);
Alex
Am Mit, 2002-06-26 um 11.14 schrieb Himmler Andreas /OI&T:
> Hi!
>
> My problem is : I plan to include over 20 buttons in one WidgetList and if I
> have to use SetEventCallback I have to write a function for each button, or
> is there another way?
>
> The things to do if a button is clicked are nearly the same for each one -
> so one big function would have been better for my reasons... Is there a way
> to send the CALLBACK-function the button-id or to check it out or something
> like that???
>
> Bye,
>
> Himmler Andreas
>
> -----Ursprüngliche Nachricht-----
> Von: Alexander Pipelka [mailto:address@hidden
> Gesendet: Mittwoch, 26. Juni 2002 10:23
> An: paragui-users
> Betreff: Re: [paragui-users] Button-ID within a WidgetList???
>
>
> These events are only passed one level up (from child to parent).
> In this case your buttons are children from the widgetlist which is a
> child of myWidget (2 levels).
>
> Please use SetEventCallback/SetEventObject (MSG_BUTTONCLICK) to connect
> your buttons.
>
> Alex
>
> Am Mit, 2002-06-26 um 10.07 schrieb Himmler Andreas /OI&T:
> > Hi!
> >
> > I made a new ThemeWidget-class which has an WidgetList in it an a few
> > buttons are in this WidgetList. How can I see, if one of these buttons is
> > pressed and test which one?
> >
> > Do I have to make a new WidgetList-class which it's own
> > eventButtonClick-function??? If yes, which things should I care of?
> >
> > Now, my code looks like:
> >
> > ....
> > myWidget::myWidget(PG_Widget* parent, PG_Rect r) :
> > PG_ThemeWidget(parent, r, true)
> > {
> > ....
> > PG_WidgetList* WL1;
> > PG_Button* Test1;
> > PG_Button* Test2;
> >
> > Test1=new PG_Button(NULL,10,PG_Rect(...),"test1");
> > Test2=new PG_Button(NULL,11,PG_Rect(...),"test2");
> >
> >
> > WL1->AddWidget(Test1);
> > WL1->AddWidget(Test2);
> > };
> >
> > myWidget::eventButtonClick(int id, PG_Widget* widget)
> > {
> > // here the prog never comes, if one of the buttons in the
> > widgetlist is pressed....
> > };
> > ....
> >
> > Tanks for all hints and tipps!
> >
> > Bye,
> >
> >
> > Himmler Andreas
> >
> >
> >
> > _______________________________________________
> > paragui-users mailing list
> > address@hidden
> > http://mail.freesoftware.fsf.org/mailman/listinfo/paragui-users
> >
>
>
>
>
> _______________________________________________
> paragui-users mailing list
> address@hidden
> http://mail.freesoftware.fsf.org/mailman/listinfo/paragui-users
>
> _______________________________________________
> paragui-users mailing list
> address@hidden
> http://mail.freesoftware.fsf.org/mailman/listinfo/paragui-users
>