Fix "Fl_Input popup menu customize doesn't work" (#874)

This commit is contained in:
ManoloFLTK 2023-12-21 15:23:38 +01:00
parent 42ff55026e
commit e466fe20c8
2 changed files with 17 additions and 9 deletions

View File

@ -52,9 +52,9 @@ const char *Fl_Input::copy_menu_text = "Copy";
const char *Fl_Input::paste_menu_text = "Paste";
static Fl_Menu_Item rmb_menu[] = {
{ Fl_Input::cut_menu_text, 0, NULL, (void*)1 },
{ Fl_Input::copy_menu_text, 0, NULL, (void*)2 },
{ Fl_Input::paste_menu_text, 0, NULL, (void*)3 },
{ NULL, 0, NULL, (void*)1 },
{ NULL, 0, NULL, (void*)2 },
{ NULL, 0, NULL, (void*)3 },
{ NULL }
};
@ -763,6 +763,9 @@ int Fl_Input::handle(int event) {
*/
Fl_Input::Fl_Input(int X, int Y, int W, int H, const char *l)
: Fl_Input_(X, Y, W, H, l) {
if (!rmb_menu[0].label()) rmb_menu[0].label(Fl_Input::cut_menu_text);
if (!rmb_menu[1].label()) rmb_menu[1].label(Fl_Input::copy_menu_text);
if (!rmb_menu[2].label()) rmb_menu[2].label(Fl_Input::paste_menu_text);
}

View File

@ -85,6 +85,13 @@ static int scroll_amount = 0;
static int scroll_y = 0;
static int scroll_x = 0;
static Fl_Menu_Item rmb_menu[] = {
{ NULL, 0, NULL, (void*)1 },
{ NULL, 0, NULL, (void*)2 },
{ NULL, 0, NULL, (void*)3 },
{ NULL }
};
// CET - FIXME
#define TMPFONTWIDTH 6
@ -189,6 +196,10 @@ Fl_Text_Display::Fl_Text_Display(int X, int Y, int W, int H, const char* l)
set_flag(SHORTCUT_LABEL);
clear_flag(NEEDS_KEYBOARD);
if (!rmb_menu[0].label()) rmb_menu[0].label(Fl_Input::cut_menu_text);
if (!rmb_menu[1].label()) rmb_menu[1].label(Fl_Input::copy_menu_text);
if (!rmb_menu[2].label()) rmb_menu[2].label(Fl_Input::paste_menu_text);
end();
}
@ -4069,12 +4080,6 @@ void Fl_Text_Display::scroll_timer_cb(void *user_data) {
Fl::repeat_timeout(.1, scroll_timer_cb, user_data);
}
static Fl_Menu_Item rmb_menu[] = {
{ Fl_Input::cut_menu_text, 0, NULL, (void*)1 },
{ Fl_Input::copy_menu_text, 0, NULL, (void*)2 },
{ Fl_Input::paste_menu_text, 0, NULL, (void*)3 },
{ NULL }
};
/** Handle right mouse button down events.
\return 0 for no op, 1 to cut, 2 to copy, 3 to paste