MacArthur, Ian (SELEX) (UK) wrote:
>> For example,
>>
>> int Fl_MyWidget::handle(int e)
>> {
>> switch(e)
>> {
>> case FL_PUSH:
>> if(callback())
>> {
>> fl_cursor(FL_CURSOR_HAND);
>
> Just a thought, but isn't FL_PUSH too late to change the cursor to a
> hand, is it not more normal to change it on FL_ENTER or something?
Yeah, this is a partial manual typing and copy and paste typo. I started out
writing the code in knode. Then I copy and pasted the if-statement. I do
have the cursor changing on a FL_ENTER event. :)
>> Then the app, assigns or removes the callback I defined as needed.
>>
>> My problem is that when I create Fl_MyWidget, its callback is
>> automagically
>> set to Fl::default_callback(). My questions are:
>
> What widget are you deriving your widget from? I wonder if that makes a
> difference to what is assigned by default? E.g. does Fl_Box get a
> default callback or not? I do not know... Might be worth a try though. I
> suspect that the deafult callback IS set for everything, however...
I'm deriving from Fl_Widget. I have a custom draw() as well. To work around
this, in Fl_MyWidget:
inline bool Fl_Canvas_Layer::has_callback()
{
return callback() && callback() != Fl_Widget::default_callback;
}
This seems to have done the trick. I guess I'm just being silly ;) I could
have simply added "bool do_interaction" and have the app set it to true.
Then handle() would just check if(do_interaction).
>> 1. What is the purpose of this callback?
>
> It puts a pointer to your widget into the fltk queue - it kind of makes
> a list of widgets that may have been modified and require processing, I
> think.
>
>> 2. Is it safe to set the callback for Fl_MyWidget (in the
>> ctor) to NULL?
>
> Erm, possibly... Certainly worth a try, I'd say. What's the worst that
> can happen... :-)
AFAICT, there were no side-effects in doing this. But I only did a whole 15
seconds of test. I think I will stick with the has_callback() workaround.
Thanks for the comments,
--
Alvin
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk