FLTK logo

Re: [fltk.general] Right clicking on a check button label

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: Right clicking on a check button label supsm17 May 06, 2022  
  Thanks a lot, I have a bit of an issue though...
Here is my code (roughly, my memory isn't perfect):

Fl_Menu_Item menu_item[] = { {"name", 0, nullptr, int_ptr } }; // here int_ptr is a int* which exists for the entire duration of the program
Fl_Menu_Button* o = new Fl_Menu_Button(400, 30, 40, 15);
o->copy(menu_item); // < here, it crashes and complains about menu_item.size()

Do you know what this might be caused by, and how it could be fixed?
On Wednesday, May 4, 2022 at 8:02:50 AM UTC-7 lifeatt...@gmail.com wrote:
Right-click is POPUP3 or 3.

> I have a Fl_Check_Button which has a label, I want some menu to pop up when I right click the label

But I see the problem. Your sample works fine if you create a Fl_Box with a label to be right-clicked over. A Fl_Check_Button, on the other hand,
is grabbing all mouse events, and the Fl_Menu_Button is never activated.

The modified version below works by making the check button really narrow and faking up a label via Fl_Box. The Fl_Menu_Button works
now because Fl_Box isn't grabbing mouse events.

#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Menu_Button.H>
#include <FL/Fl_Check_Button.H>
#include <FL/Fl_Box.H>


Fl_Menu_Item menu_menu[] = {
 {"item", 0,  0, 0, 0, (uchar)FL_NORMAL_LABEL, 0, 14, 0},
 {0,0,0,0,0,0,0,0,0}
};

int main(int argc, char **argv) {
  Fl_Double_Window* w;
  { Fl_Double_Window* o = new Fl_Double_Window(120, 100);
    w = o; if (w) {/* empty */}
    { Fl_Menu_Button* o = new Fl_Menu_Button(25, 25, 69, 20, "menu");
      o->type(Fl_Menu_Button::POPUP3);

      o->menu(menu_menu);
    } // Fl_Menu_Button* o
    auto cb = new Fl_Check_Button(20,25,20,20);
    auto bx = new Fl_Box(25,25,100,20,"CB Label");

    o->end();
  } // Fl_Double_Window* o
  w->show(argc, argv);
  return Fl::run();
}

Someone smarter than me might know how to create a Fl_Check_Button which doesn't grab the right mouse button.

--
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/8fa203b3-4600-49d3-bc97-ba14b1d1339cn%40googlegroups.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'.