Adds Fl_Input RMB menu translation to test/preferences

This also updates the RMB menu labels before every popup so
that changing the labels after creating the widgets still reflects
that change correctly.
This commit is contained in:
Matthias Melcher 2023-12-28 15:43:21 +01:00
parent 30f2ec8185
commit a09c75e9bc
3 changed files with 23 additions and 14 deletions

View File

@ -524,7 +524,12 @@ int Fl_Input::handle_rmb() {
insert_position(word_start(newpos), word_end(newpos));
}
}
if (readonly()) { // give only the menu options that make sense
// keep the menu labels current
rmb_menu[0].label(Fl_Input::cut_menu_text);
rmb_menu[1].label(Fl_Input::copy_menu_text);
rmb_menu[2].label(Fl_Input::paste_menu_text);
// give only the menu options that make sense
if (readonly()) {
rmb_menu[0].deactivate(); // cut
rmb_menu[2].deactivate(); // paste
} else {
@ -763,9 +768,6 @@ 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

@ -196,10 +196,6 @@ 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();
}
@ -4104,7 +4100,12 @@ int Fl_Text_Display::handle_rmb(int readonly) {
txtbuf->select(txtbuf->word_start(newpos), txtbuf->word_end(newpos));
}
}
if (readonly) { // give only the menu options that make sense
// keep the menu labels current
rmb_menu[0].label(Fl_Input::cut_menu_text);
rmb_menu[1].label(Fl_Input::copy_menu_text);
rmb_menu[2].label(Fl_Input::paste_menu_text);
// give only the menu options that make sense
if (readonly) {
rmb_menu[0].deactivate(); // cut
rmb_menu[2].deactivate(); // paste
} else {

View File

@ -66,6 +66,8 @@ for systems that don't have GNU libintl library.} open return_type {const char*}
{ "Bread:", "Brot:" },
{ "Breakfast:", "Frühstück:" },
{ "Cancel", "Abbrechen" },
{ "Copy", "Kopieren" },
{ "Cut", "Ausschneiden" },
{ "Drink:", "Getränk:" },
{ "English", "Englisch" },
{ "German", "Deutsch" },
@ -75,6 +77,7 @@ for systems that don't have GNU libintl library.} open return_type {const char*}
{ "NY Times", "Der Spiegel" },
{ "Newspaper:", "Tageszeitung:" },
{ "OK", "OK" },
{ "Paste", "Einfügen" },
{ "Please restart the app to use your new language setting.",
"Bitte starten Sie die App erneut um Ihre Spracheinstellung zu nutzen." },
{ "Wear:", "Schuhwerk:" },
@ -103,7 +106,7 @@ for systems that don't have GNU libintl library.} open return_type {const char*}
{ "with milk", "mit Milch" },
};
int lang = g_language;
int i, n = 38;
int i, n = 41;
const char *found = 0L;
// As this is just a minimal demo, I did not implement binary search.
@ -132,7 +135,11 @@ Fl::delete_widget(myWindow);} {}
Function {} {open return_type int
} {
code {readLanguagePrefs();} {}
code {readLanguagePrefs();
Fl_Input::cut_menu_text = gettext("Cut");
Fl_Input::copy_menu_text = gettext("Copy");
Fl_Input::paste_menu_text = gettext("Paste");} {selected
}
Fl_Window myWindow {
label {My Preferences}
callback closeWindowCB open
@ -140,7 +147,7 @@ Function {} {open return_type int
} {
Fl_Button {} {
label Cancel
callback closeWindowCB selected
callback closeWindowCB
xywh {118 316 90 24}
}
Fl_Button {} {
@ -470,6 +477,5 @@ Function {writePrefs()} {open return_type void
// unsigned int size_of_bed = sizeof( bed ); // size of Fl_Preferences 'bed'
// eat.set( "binFoo", (void*)&hex, sizeof( unsigned int ) );
// eat.set( "SizeOfBed", (int)size_of_bed );
// eat.set( "Prefs_Bed", (void*)&bed, sizeof( bed ) );} {selected
}
// eat.set( "Prefs_Bed", (void*)&bed, sizeof( bed ) );} {}
}