Fix inconsistent handling of Control, Alt, and Shift keys through a new modifier update callback.

master
Geenz 2013-02-22 16:41:49 -05:00
parent e17d69d1d1
commit 4a935b6815
8 changed files with 28 additions and 2 deletions

View File

@ -83,6 +83,11 @@ public:
virtual BOOL handleKeyUp(const U16 key, MASK mask) = 0;
virtual BOOL handleKeyDown(const U16 key, MASK mask) = 0;
#ifdef LL_DARWIN
// We only actually use this for OS X.
virtual void handleModifier(MASK mask) = 0;
#endif // LL_DARWIN
// Asynchronously poll the control, alt, and shift keys and set the
// appropriate internal key masks.
virtual void resetMaskKeys() = 0;

View File

@ -45,6 +45,13 @@ BOOL LLKeyboardHeadless::handleKeyUp(const U16 key, const U32 mask)
MASK LLKeyboardHeadless::currentMask(BOOL for_mouse_event)
{ return MASK_NONE; }
#ifdef LL_DARWIN
void LLKeyboardHeadless::handleModifier(MASK mask)
{
}
#endif
void LLKeyboardHeadless::scanKeyboard()
{
for (S32 key = 0; key < KEY_COUNT; key++)

View File

@ -40,6 +40,9 @@ public:
/*virtual*/ void resetMaskKeys();
/*virtual*/ MASK currentMask(BOOL for_mouse_event);
/*virtual*/ void scanKeyboard();
#ifdef LL_DARWIN
/*virtual*/ void handleModifier(MASK mask);
#endif
};
#endif

View File

@ -198,6 +198,11 @@ static BOOL translateKeyMac(const U16 key, const U32 mask, KEY &outKey, U32 &out
}
*/
void LLKeyboardMacOSX::handleModifier(MASK mask)
{
updateModifiers(mask);
}
MASK LLKeyboardMacOSX::updateModifiers(const U32 mask)
{
// translate the mask

View File

@ -49,6 +49,7 @@ public:
/*virtual*/ void resetMaskKeys();
/*virtual*/ MASK currentMask(BOOL for_mouse_event);
/*virtual*/ void scanKeyboard();
/*virtual*/ void handleModifier(MASK mask);
protected:
MASK updateModifiers(const U32 mask);

View File

@ -345,6 +345,7 @@
- (void)flagsChanged:(NSEvent *)theEvent {
mModifiers = [theEvent modifierFlags];
callModifier([theEvent modifierFlags]);
}
- (void) mouseDown:(NSEvent *)theEvent
@ -433,8 +434,6 @@
callMouseExit();
}
- (NSPoint)convertToScreenFromLocalPoint:(NSPoint)point relativeToView:(NSView *)view
{
NSScreen *currentScreen = [NSScreen currentScreenForMouseLocation];

View File

@ -95,6 +95,7 @@ void callMiddleMouseDown(float *pos, unsigned int mask);
void callMiddleMouseUp(float *pos, unsigned int mask);
void callFocus();
void callFocusLost();
void callModifier(unsigned int mask);
#include <string>
void callHandleDragEntered(std::string url);

View File

@ -337,6 +337,11 @@ void callMiddleMouseUp(float *pos, MASK mask)
gWindowImplementation->getCallbacks()->handleMiddleMouseUp(gWindowImplementation, outCoords, mask);
}
void callModifier(MASK mask)
{
gKeyboard->handleModifier(mask);
}
void callHandleDragEntered(std::string url)
{
gWindowImplementation->handleDragNDrop(url, LLWindowCallbacks::DNDA_START_TRACKING);