Dave Williss wrote:
We've discovered a problem with accelerator keys in Lesstif...
If you have an accelerator "Ctrl<Key>c" it fails to detect the ctrl-c if
either the Caps Lock or NumLock keys are on.
I have had the same problem with OSF Motif, both 1.2 on SGI/Irix, 2.1 on same, and 2.1 (openmotif) on Linux. So I would say this is not a bug but a feature, and should be left as-is to enhance compatibility.
As an application look-and-feel issue, the users of my app decided that numlock and caplock should not affect CTRL accelerators; this is implemented automatically by scanning the widget tree and replacing, e.g., "Alt<Key>P" by
"Alt<Key>P,Lock Alt<Key>P,Mod3 Alt<Key>P,Lock Mod3 Alt<Key>P"
Looking through Manager.c, I find this in _XmAcceleratorHandler...
if (/*MGR_KeyboardList(w)[i].eventType == event->type && */ MGR_KeyboardList(w)[i].key == event->xkey.keycode && MGR_KeyboardList(w)[i].modifiers == event->xkey.state && MGR_KeyboardList(w)[i].component == comp && XtIsManaged(comp))
The problem is that it's comparing event->xkey.state in such a way that if any other state bit is on, it will fail. I changed that line to...
(MGR_KeyboardList(w)[i].modifiers & event->xkey.state) == MGR_KeyboardList(w)[i].modifiers
thinking that would solve my problem, but it didn't. It turns out that in AddKeyboardEntry, it calls XtGrabKey with the modifiers we want. But if a keypress comes in with any other modifiers, the event won't even get to XmAcceleratorHandler. My short-term solution was to add more XtGrabKey lines such as...
XtGrabKey(m, item->key, item->modifiers | LockMask, False, GrabModeAsync, GrabModeAsync); XtGrabKey(m, item->key, item->modifiers | Mod2Mask, False, GrabModeAsync, GrabModeAsync); XtGrabKey(m, item->key, item->modifiers | Mod2Mask | LockMask, False, GrabModeAsync, GrabModeAsync);
From what I can tell, Mod2Mask == NumLock. I don't know if that's alwaysthe case though. Then in DeleteKeyboardEntry, I had to to XtUngrabKeys to match the extra grabs.
Now the problem with all this is 1) it might be incomplete. Maybe should check Mod3Mask and Mod4Mask? what are they used for? Mod1Mask seems to be the Alt key 2) Technically, an accelerator can be specified as "!Ctrl<Key>c" which means the Ctrl modifier with no others, in which case we wouldn't want to do all of this. Unfortunately, I couldn't figure out how to determine if we had that in the places I needed to check it. The XmKeyboardData structure would need to keep track of this
-- Dave Williss
Greetings, -- Michel Bardiaux Peaktime Belgium S.A. Bd. du Souverain, 191 B-1160 Bruxelles Tel : +32 2 790.29.41
------------------------------------------------------- This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php _______________________________________________ Lesstif-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/lesstif-discuss

