Albrecht Schlosser schrieb:
> Michael Schmid wrote:
>> Hi!
>>
>> How can I find out with below_mouse(), if there is a spesific widget 
>> under the mouse? I didn't find any examples and also don't understand 
>> how to use it exactly...
>>
>> Could anyone post some code :-) I need it in the form:
>>
>> if(mouse under a specific widget)
>> {
>> ...
>> }
> 
> The normal FLTK way is something like "the other way around". A widget 
> that gets an FL_ENTER event must return 1 on this event in its handle() 
> method to become the Fl::belowmouse() widget. Then it will also get 
> FL_MOVE and FL_LEAVE events. Maybe this is all you need.
> 
> Fl::belowmouse() will tell you, which widget is the current "belowmouse" 
> widget (but this can also be NULL). But this will only work, if your 
> widget's event handling does, what I described above.
> 
> If you want to know, which widget is currently under the mouse pointer 
> at any given time, then you would need to walk the widget tree yourself 
> and check every widget (group) recursively (or you need a table of all 
> relevant widgets for this check).
> 
> Albrecht

What I finally need is the following behaviour:

Button unpressed: Picture 1 is shown on button
Button pressed: Picture 2 is shown on button
A function is called if you release the button, but just if you release 
it on the button. If the button gets released, because you move the 
mouse away from the button, then the function shouldn't be called.

To show the two pictures I configurated the button as FL_WHEN_CHANGED 
and did the following code in the callback:

static void fCallbackButtonHelp(Fl_Button*, void *)
{
        if (pMainButtonHelp->value())
        {
                pMainButtonHelp->image(pPixmapHelpPressed);
        }
        else
        {
                pMainButtonHelp->image(pPixmapHelpUnpressed);
                fFunctionToBeCalled();
        }
}

I thought that I can maybe make another "if" to call the 
fFunctionToBeCalled just if the mouse is still on the button (i.e. the 
callback was not called because the mouse was moved away, but because 
the mouse was released on the button....)
Is there any simple solution for this?

FLTK: 1.1.9

Thanks!
Michael

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to