Albrecht Schlosser wrote:
>> Feedback welcome.
>
> From the FLTK 1.1 docs (Enumerations):
>
> FL_META - One of the meta/Windows keys is down.
> FL_COMMAND - An alias for FL_CTRL on WIN32 and X11, or FL_META on MacOS X.
>
> So, would this need to be platform dependent?
No, the new code wouldn't need to be platform aware; it'd just be an
alias
for the already platform aware FL_COMMAND.
Keep in mind the string shortcuts like "^F" are just converted
to the integer equivalent via fl_old_shortcut(), which looks like this:
unsigned int fl_old_shortcut(const char* s) {
if (!s || !*s) return 0;
unsigned int n = 0;
if (*s == '#') {n |= FL_ALT; s++;}
if (*s == '+') {n |= FL_SHIFT; s++;}
if (*s == '^') {n |= FL_CTRL; s++;}
if (*s && s[1]) return n | (int)strtol(s,0,0); // allow 0xf00 to get any key
return n | *s;
}
So if we were to say go with Mike's recommendation for '!',
then the additional code would just be:
if (*s == '!') {n |= FL_COMMAND; s++;}
..so the already platform specific behavior of FL_COMMAND would just be
carried over by extension.
> How would it show up under Windows in the shown menu text?
It would do whatever behavior FL_COMMAND does now, since the new code
is just an alias for the macro.
> What about FL_META?
Indeed! We should probably add both FL_COMMAND and FL_META as separate
shortcut codes, eg:
if (*s == '!') {n |= FL_COMMAND; s++;}
if (*s == '&') {n |= FL_META; s++;}
..where ! and & are still up for vote; just needed to put something
there ;)
> [..Enumerations excerpt snipped..] Sorry for potential wrapping. The latter
> (FL_CONTROL = "An alias for
> FL_META on WIN32 and X11, or FL_META on MacOS X" is obviously wrong,
> this should probably read "An alias for FL_META on WIN32 and X11, or
> *FL_CTRL* on MacOS X". Should we fix this?
Indeed, the comment appears to be wrong.
I believe FL_COMMAND and FL_CONTROL are intended to be precisely
opposite,
and are named from the Apple keyboard's point of view.
According to the code (not the comments):
Macro Apple Behavior Windows/Unix Behavior
---------- -------------- ---------------------
FL_COMMAND FL_META FL_CTRL
FL_CONTROL FL_CTRL FL_META
The reasoning here is these are Apple-centric names for the keys;
apple has 3 special modifier keys besides FL_SHIFT:
"Control" -- FL_CTRL
"Alt/Option" -- FL_ALT
"(Apple)/(Cloverleaf)/Command" -- FL_META
..and of course the confusing cross platform issue is on macs COMMAND-C
is the way to do unix/win CTRL-C, and is the reason these backwards
macros exist.
On Windows, the 'Microsoft Windows Key' generates the same
keycode/function
as the Apple/Cloverleaf/Command key, and are physically in the same
position
on the keyboard.
I *think* Matthias helped add these when fixing problems with cross
platform
shortcuts, so he can probably weigh in with further details. But I
think the
above is correct.
> Having read all the other comments, I'm -1 on non-ASCII encodings,
> and my suggestion would probably be '~', because it's similar to
> "^" (FL_CTRL) on WIN32/X11.
Ah, good to know your reasoning.
However, I think these keys (FL_COMMAND and FL_CONTROL) are "Apple
centric" names,
so it follows the mnemonics would be Apple keyboard oriented, me thinks.
Also, the above regarding FL_COMMAND and FL_CONTROL being Apple
keyboard-centric naming
should probably be highlighted in the docs, as to the casual glance of
an app programmer,
one might not easily catch FL_CTRL and FL_CONTROL are two entirely
different things
on windows/unix, ie. my additions underlined and Albrecht's fix
implemented as well:
# define FL_COMMAND FL_META ///< Apple-centric keyboard name, aka. "Apple"
or "Cloverleaf" key: an alias for FL_CTRL on WIN32 and X11, or FL_META on MacOS
X
# define FL_CONTROL FL_CTRL ///< Apple-centric keyboard name, an alias for
FL_META on WIN32 and X11, or FL_CTRL on MacOS X
Probably the docs on keyboards should clarify this as well, pointing
out the
platform differences in Mac vs Win/Linux for things like ctrl-c vs.
meta-c,
and thus the reason for these seemingly confusingly named macros are
actually
desirable negative logic to undo the confusing differences across
platforms.
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev