On 21 Jul 2007, at 17:55, Owen wrote:

> I am creating a program, and want to create a widget that has a  
> callback, but is not a button. I am using fltk2, and I have created  
> this box using fltk::Widget. I want to be able to both left and  
> right click on it to perform different actions, however I don't  
> want to be able to push tab to get to it like I would a fltk::Button.
>
> I am guessing I can use
>
> widget_name -> callback(callback_name,this);
>
> but can't seem to be able to do it, I have used callbacks for  
> normal buttons no problem.

If you are making your own widget, sub-classed from Fl_Widget (FWIW I  
would usually subclass from Fl_Box instead, btw!) you are probably  
better just using the sub-classed handle() method to cope with the  
mouse clicks on your widget. That is a much more direct way to handle  
the clicks than trying to mess about getting the callback to do what  
you want.

I'd guess there's worked examples of this on Greg's cheat-sheet: this  
one
  http://www.seriss.com/people/erco/fltk/#DraggableBoxes

shows how to subclass from Fl_Box and write your own handle method.  
Simple enough to take that and extend it to detect your left/right  
mouse clicks instead.

As to making the widget not participate in keyboard navigation (i.e.  
so you can't tab to it) then it should be enough to just do my_widget- 
 >clear_visible_focus();
I quote the docs; "Disables keyboard focus navigation with this  
widget; normally, all widgets participate in keyboard focus navigation."

-- 

Ian


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

Reply via email to