FLTK logo

Re: [fltk.general] Suggestion for Point selector widget Fl_Point

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Suggestion for Point selector widget Fl_Point Greg Ercolano Oct 19, 2021  
 


On 10/19/21 11:00 AM, anmol....@gmail.com 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.

    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".

    For drawing the cursor, you could try using the overlay plane stuff, but these days
    most machines are fast enough you can redraw the image/visual element and draw
    the cursor over that, redrawing each time the mouse FL_MOVE events are received.
    Just be sure to use an Fl_Double_Window so there's no flicker.

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/09ca8236-1764-cc21-9e4e-86e284a556ed%40seriss.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.