Fl_Tree

18 views
Skip to first unread message

holm.h...@gmail.com

unread,
Feb 26, 2021, 6:11:06 AM2/26/21
to fltk.general

Hello,

Is it possible to make Fl_Tree repond (callbakc) to right-mouse-click ?

Best regards
Håvard

lifeatt...@gmail.com

unread,
Feb 26, 2021, 7:46:04 AM2/26/21
to fltk.general
>Is it possible to make Fl_Tree repond (callbakc) to right-mouse-click ?

Yes. Create a class derived from Fl_Tree, add a custom handle() override, examine the FL_PUSH event, and check for
Fl::event_button() == FL_RIGHT_MOUSE

holm.h...@gmail.com

unread,
Feb 26, 2021, 9:10:13 AM2/26/21
to fltk.general

Hi,
Still having problems, I write my handle function:
int ERS_Tree::handle(int e){
  int ret;
  if ( (e==FL_PUSH) && (Fl::event_button() == FL_RIGHT_MOUSE))
      My_Tree_cb(this, NULL);
  ret Fl_Tree::handle(e);
  return ret;
}
In my My_Tree_cb, I call:
   Fl_Tree_Item *item;
   item   = w->callback_item();
item is however not pointing to the item which I clicked.

I have missed something - but what ?

Best regards
Håvard

lifeatt...@gmail.com

unread,
Feb 26, 2021, 9:26:17 AM2/26/21
to fltk.general
>item is however not pointing to the item which I clicked.

I'm just looking at the FL_Tree handle() code. To find the active item, it calls:

 Fl_Tree_Item *item = _root->find_clicked(_prefs, 0);

_root and _prefs look like they won't be accessible so you'll need to use the accessor methods.

Philip Rose

unread,
Feb 26, 2021, 9:51:31 AM2/26/21
to fltkg...@googlegroups.com

Could you call the Fl_Tree::handle() before the callback is invoked? That would make sure the active item gets identified and there might be other stuff that gets done.

 

Phil.

 

Sent from Mail for Windows 10

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/1b9966b1-c567-46bf-8bc8-48c459bf9c66n%40googlegroups.com.

 

holm.h...@gmail.com

unread,
Feb 26, 2021, 10:10:25 AM2/26/21
to fltk.general

Thanks !

Your hint to "find_clicked" made my day !

Best regards
Håvard
Message has been deleted

lifeatt...@gmail.com

unread,
Feb 26, 2021, 2:32:06 PM2/26/21
to fltk.general
[trying again, Google Group messed up my reply]
>Could you call the Fl_Tree::handle() before the callback is invoked? That would make sure the active item gets identified and there might be other >stuff that gets done.

Good idea but alas, it won't work. Fl_Tree::handle() only calls find_clicked() for FL_LEFT_MOUSE events ...

Reply all
Reply to author
Forward
0 new messages