summaryrefslogtreecommitdiff
path: root/src/ui/util.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-07-22 08:38:37 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-07-22 08:38:37 +0300
commitbc07d618e27147a8510f2077d0e3708aaa467e27 (patch)
tree7441065f9b27739ae17575a795f63c204ef26577 /src/ui/util.c
parentb2448c68011f310e312de61cbfea86059ef730da (diff)
Added a setting for Return key behavior
User preference for line break / accept behavior in input fields. Still needs to be added to the Preferences dialog.
Diffstat (limited to 'src/ui/util.c')
-rw-r--r--src/ui/util.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/ui/util.c b/src/ui/util.c
index da7a69b4..63600557 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -169,6 +169,13 @@ int keyMods_Sym(int kmods) {
169 return kmods; 169 return kmods;
170} 170}
171 171
172int keyMod_ReturnKeyFlag(int flag) {
173 flag &= mask_ReturnKeyFlag;
174 const int kmods[4] = { 0, KMOD_SHIFT, KMOD_CTRL, KMOD_GUI };
175 if (flag < 0 || flag >= iElemCount(kmods)) return 0;
176 return kmods[flag];
177}
178
172int openTabMode_Sym(int kmods) { 179int openTabMode_Sym(int kmods) {
173 const int km = keyMods_Sym(kmods); 180 const int km = keyMods_Sym(kmods);
174 return (km == KMOD_SHIFT ? otherRoot_OpenTabFlag : 0) | /* open to the side */ 181 return (km == KMOD_SHIFT ? otherRoot_OpenTabFlag : 0) | /* open to the side */
@@ -1307,12 +1314,14 @@ iWidget *makeValueInput_Widget(iWidget *parent, const iString *initialValue, con
1307 setId_Widget(as_Widget(input), "input"); 1314 setId_Widget(as_Widget(input), "input");
1308 updateValueInputWidth_(dlg); 1315 updateValueInputWidth_(dlg);
1309 addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI))); 1316 addChild_Widget(dlg, iClob(makePadding_Widget(gap_UI)));
1310 addChild_Widget( 1317 addChild_Widget(dlg,
1311 dlg, 1318 iClob(makeDialogButtons_Widget(
1312 iClob(makeDialogButtons_Widget( 1319 (iMenuItem[]){ { "${cancel}", SDLK_ESCAPE, 0, "valueinput.cancel" },
1313 (iMenuItem[]){ { "${cancel}", SDLK_ESCAPE, 0, "valueinput.cancel" }, 1320 { acceptLabel,
1314 { acceptLabel, 0, 0, "valueinput.accept" } }, 1321 SDLK_RETURN,
1315 2))); 1322 acceptKeyMod_ReturnKeyBehavior(prefs_App()->returnKey),
1323 "valueinput.accept" } },
1324 2)));
1316 finalizeSheet_Mobile(dlg); 1325 finalizeSheet_Mobile(dlg);
1317 if (parent) { 1326 if (parent) {
1318 setFocus_Widget(as_Widget(input)); 1327 setFocus_Widget(as_Widget(input));