Murga-Projects Forums

Full Version: FL_PUSH on arbitrary area
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is it possible to detect FL_PUSH when it isn't done on a button widget?
I've been trying to place points according to mouse clicks on a given region, but Fl:event() aways returns 0 because the region isn't a button. I can test for FL_NO_EVENT and use that, but it is not very reliable because FL_NO_EVENT returns true for both a mouse press and release, and it may return true from other unwanted events.

It doesn't seem logical for Fl:event() to check for a particular type of widget. It seems to me that it _should_ work whenever you click a mouse button, regardless of where the mouse is.

Fl:event_button() and similar didn't work either, since they seem to rely on a test for FL_PUSH
Did you look at my earlier graphics demos, I don't know exactly how I pulled it off, its been months now. But that places those rectangles or circles at any point the mouse is down on.
The last time I looked at the non-segfaulty one (murgaFLTKDrawFunctions) I had no idea at all of how drawing worked, so I kind of stayed away from looking at the source...then of course forgot that it includes mouse tracking.

Looking at it now....

[time passes]

...hmmm, I see "if Fl:event()==5 or Fl:event()==1 then", but I don't think that would be it considering my test of Fl:event() always returned 0 when clicking a mouse button...
Checking for event 5 (drag) sort of works, although it doesn't give the behavior I'm looking for (click to draw a line from the previous click to the current one). It does look a whole lot better than my previous freehand drawing experiment, though, which simply spit out 1000 tiny rectangles per second as you drag the mouse, so I think I'm going to dump the old version.
The above makes me wonder even more if this is a bug. Why would a drag in an arbitrary location be correctly detected, but a click is not?

[more time passes]

Nope, I'm not seeing how it works =o(
I can think of two things that might possibly have an affect, but they are both wild guesses. One is the w:callback(), which may have some influence over Fl:event(). The other is w:make_current(), which I can't seem to make work in my situation. I'm using a nested window, and when I try to make the parent window active from the child script it segfaults, so I have to make the child window the active one. That works fine for the actual drawing, but I wonder if it affects how events are received.

The quaddraw examples use the same check for event 5 or 1, so I dunno what I'm missing.

I suppose it could also be that I'm using a timer which checks for the events. It seems to me that this shouldn't be necessary, but I don't know how else to do it...unless that's what Fl:wait() is for?...i'll have to check that out

mikshaw Wrote:
I suppose it could also be that I'm using a timer which checks for the events. It seems to me that this shouldn't be necessary, but I don't know how else to do it...unless that's what Fl:wait() is for?...i'll have to check that out


That is exactly what Fl:wait() is for ... Unfortunately I haven't had ANY time to look after murgaLua lately, but as of Friday things should be back on track.

Cheers
JohnM

Reference URL's