You are killing me I get all my mouse coords from eBay :-)owen wrote:how do i get mouse x,y from image or the box containing the image?
There are more than ten solution to get such things like mouse coords in FLTK.
It depends from on which point in your application do you need it.
first take a look at this small code:
Code: Select all
#include once "fltk-c.bi"
var win = Fl_WindowNew(320,240)
var box = Fl_BoxNew2(BoxType(FL_GLEAM_DOWN_BOX),50,50,Fl_WidgetGetW(win)-100,Fl_WidgetGetH(win)-100)
Fl_WindowShow(win)
Fl_Run()
Ok so far ?
As an FLTK beginners the only chance are to interact with your GUI application are you don't use Fl_Run() instead you can use Fl_Wait().
Fl_Wait() waits for any event and returns 0 if no more Windows are open.
Here are how this beginner friendly solution works.
Code: Select all
#include once "fltk-c.bi"
var win = Fl_WindowNew(320, 240)
var box = Fl_BoxNew2(BoxType(FL_GLEAM_DOWN_BOX),50,50,Fl_WidgetGetW(win)-100,Fl_WidgetGetH(win)-100)
Fl_WindowShow(win)
while Fl_Wait()
var event=Fl_EventNumber()
' is it a mouse move and inside the box
if event = FL_EVENT_MOVE and Fl_EventInside(box) then
' print the mouse coords relative to the box X,Y origin
print event,Fl_EventX()-Fl_WidgetGetX(box),Fl_EventY()-Fl_WidgetGetY(box)
end if
wend
Fl_EventNumber, Fl_EventButton,Fl_EventButton1, Fl_EventButton2, Fl_EventButton3
Fl_EventButtons, Fl_GetEventClicks, Fl_GetEventIsClick, Fl_EventKey
Fl_EventAlt , Fl_EventCtrl, Fl_EventShift, Fl_EventCommand, Fl_EventText
Fl_EventX, Fl_EventY, Fl_EventXRoot, Fl_EventYRoot, Fl_EventDX, Fl_EventDY
Fl_EventClipboardData, Fl_EventClipboardType
But remember, if you book me as your personal FLTK coach I'm not cheap. :lol:
Joshy