I am trying to create a widget that can be pointed into a box to select the pixel co-ordinates within. It has a click box next to it to activate the point selection crosshairs, and then the point co-ordinates inside the box will be selected.
Any suggestions ?
I'd suggest deriving a widget from Fl_Group that implements
this pixel coordinate picking
behavior, handle() to track the mouse movement. If I remember
correctly, in response to
FL_ENTER, return 1 so your widget gets FL_MOVE events, which
gives tells you where the
mouse is whenever it moves. Save the x/y coords from FL_MOVE
in your widget and trigger
a redraw() so that your draw() routine can draw() the
crosshairs over the child widget.
Then your app can create this widget as the parent, and make
the widget with the
visual elements to be picked a child of that. (e.g. an Fl_Box
with an image() assigned to it)
For flexibility, you'd probably want to implement this
Fl_Group oriented widget
so that a callback can be set to get the 'picking' events, so
your app knows what to
do when something is "picked".
Is there also an example for Fl_Counter widget or related without the arrows ? The user can simply click and re-enter value or click and move mouse for the value to increase - depending on whether the movement is to the right or left ?Kind of like Fl_Scroller with an invisible scroll and just the value visible.
On 10/19/21 11:00 AM, anmol wrote:
I am trying to create a widget that can be pointed into a box to select the pixel co-ordinates within. It has a click box next to it to activate the point selection crosshairs, and then the point co-ordinates inside the box will be selected.
Any suggestions ?
I'd suggest deriving a widget from Fl_Group that implements this pixel coordinate picking
behavior, handle() to track the mouse movement. If I remember correctly, in response to
FL_ENTER, return 1 so your widget gets FL_MOVE events, which gives tells you where the
mouse is whenever it moves. Save the x/y coords from FL_MOVE in your widget and trigger
a redraw() so that your draw() routine can draw() the crosshairs over the child widget.