On 01/04/14 06:50, Tharindu Amila Perera wrote: > Hi all, > > Using the reply I found out that the events coming from the keyboard > has this behavior. > > Using the argument KeyEvent coming to function in file tabvwsh4.cxx > bool ScTabViewShell::TabKeyInput(const KeyEvent& rKEvt) > > > I can get codes of all keys except of Caps-Lock, NumLock and > Scroll(Which is the needed input).
> I noticed that when any of the above keys are pressed this function is > called twice. But in both events the keycodes are not accessible. hmm... indeed the keycode is 0 there... it looks like the "lock" keys are not mapped to a keycode in VCL... perhaps intentionally. > When CapsLock is on pressing key 'A' in keyboard will give the same > keycode as when it is not on. So there must be a place where it is > handled to differentiate a and A inputs. It would be appreciated if I > can get a code pointer for this. if i read the bug correctly you don't actually need the key events, you just need to know if the lock key is active when some other input happens. vcl/unx/generic/app/saldisp.cxx: sal_uInt16 SalDisplay::GetIndicatorState() const { unsigned int _state = 0; sal_uInt16 nState = 0; XkbGetIndicatorState(pDisp_, XkbUseCoreKbd, &_state); if ((_state & 0x00000001)) nState |= INDICATOR_CAPSLOCK; if ((_state & 0x00000002)) nState |= INDICATOR_NUMLOCK; if ((_state & 0x00000004)) nState |= INDICATOR_SCROLLLOCK; return nState; } there is an example for requesting the caps-lock key state in editeng/source/misc/svxacorr.cxx: bool bLockKeyOn = pFrameWin && (pFrameWin->GetIndicatorState() & INDICATOR_CAPSLOCK); so you need a VCL Window to get the state; a SfxViewShell like the ScTabVierwShell has a pointer to its Window. (since i read the bug too late i've already got a patch to assign a keycode for the scroll-lock key (see attachment), but i now think that is actually useless)
diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx index d96fd20..4960931 100644 --- a/vcl/unx/generic/app/saldisp.cxx +++ b/vcl/unx/generic/app/saldisp.cxx @@ -1251,6 +1251,9 @@ sal_uInt16 SalDisplay::GetKeyCode( KeySym keysym, char*pcPrintable ) const nKey = KEY_SEMICOLON; *pcPrintable = ';'; break; + case XK_Scroll_Lock: + nKey = KEY_SCROLLLOCK; + break; // - - - - - - - - - - - - - Apollo - - - - - - - - - - - - - 0x1000 case 0x1000FF02: // apXK_Copy nKey = KEY_COPY; diff --git a/vcl/unx/gtk/window/gtksalframe.cxx b/vcl/unx/gtk/window/gtksalframe.cxx index f22b54e..baa94f2 100644 --- a/vcl/unx/gtk/window/gtksalframe.cxx +++ b/vcl/unx/gtk/window/gtksalframe.cxx @@ -255,6 +255,7 @@ static sal_uInt16 GetKeyCode( guint keyval ) case GDK_bracketleft: nCode = KEY_BRACKETLEFT; break; case GDK_bracketright: nCode = KEY_BRACKETRIGHT; break; case GDK_semicolon: nCode = KEY_SEMICOLON; break; + case GDK_Scroll_Lock: nCode = KEY_SCROLLLOCK; break; // some special cases, also see saldisp.cxx // - - - - - - - - - - - - - Apollo - - - - - - - - - - - - - 0x1000 case 0x1000FF02: // apXK_Copy diff --git a/vcl/win/source/window/salframe.cxx b/vcl/win/source/window/salframe.cxx index 90b36e0..227b6ae 100644 --- a/vcl/win/source/window/salframe.cxx +++ b/vcl/win/source/window/salframe.cxx @@ -666,7 +666,7 @@ static const sal_uInt16 aImplTranslateKeyTab[KEY_TAB_SIZE] = 0, // 142 0, // 143 0, // NUMLOCK 144 - 0 // SCROLLLOCK 145 + KEY_SCROLLLOCK // SCROLLLOCK 145 }; static UINT ImplSalGetWheelScrollLines()
_______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice