[DEV] correct kaybord and mose input for MacOs ==> pb on close Windows

This commit is contained in:
Edouard DUPIN 2015-05-15 23:43:33 +02:00
parent bec114d53d
commit 6bcb491f0a
9 changed files with 272 additions and 275 deletions

View File

@ -11,6 +11,6 @@
@interface MacOsAppDelegate : NSObject <NSApplicationDelegate> @interface MacOsAppDelegate : NSObject <NSApplicationDelegate>
@property (assign) IBOutlet NSWindow *window; @property (assign) IBOutlet NSWindow *window;
- ()sendEvent:(NSEvent *)event; - (void)sendEvent:(NSEvent *)event;
- ()applicationWillResignActive:(MacOsAppDelegate *)application; - (void)applicationWillResignActive:(MacOsAppDelegate *)application;
@end @end

View File

@ -16,10 +16,7 @@
@synthesize window=_window; @synthesize window=_window;
- (BOOL)application:(MacOsAppDelegate *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - (BOOL)application:(MacOsAppDelegate *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
OpenGLView *view=[[OpenGLView alloc]initWithFrame:[[NSScreen mainScreen] bounds]]; OpenGLView *view=[[OpenGLView alloc]initWithFrame:[[NSScreen mainScreen] frame]];
// Override point for customization after application launch.
[self.window addSubview:view];
[self.window makeKeyAndVisible];
return YES; return YES;
} }

View File

@ -110,8 +110,9 @@ class MacOSInterface : public ewol::Context {
} }
void MAC_SetKeyboardMove(ewol::key::Special& _special, void MAC_SetKeyboardMove(ewol::key::Special& _special,
enum ewol::key::keyboard _move, enum ewol::key::keyboard _move,
bool _isDown) { bool _isDown,
OS_SetKeyboardMove(_special, _move, _isDown); bool _isAReapeateKey) {
OS_SetKeyboardMove(_special, _move, _isDown, _isAReapeateKey);
} }
void openURL(const std::string& _url) { void openURL(const std::string& _url) {
std::string req = "open " + _url; std::string req = "open " + _url;
@ -160,11 +161,11 @@ void MacOs::setKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool
interface->MAC_SetKeyboard(_keyboardMode, _unichar, _isDown, _isAReapeateKey); interface->MAC_SetKeyboard(_keyboardMode, _unichar, _isDown, _isAReapeateKey);
} }
void MacOs::setKeyboardMove(ewol::key::Special& _keyboardMode, enum ewol::key::keyboard _move, bool _isDown) { void MacOs::setKeyboardMove(ewol::key::Special& _keyboardMode, enum ewol::key::keyboard _move, bool _isDown, bool _isAReapeateKey) {
if (interface == nullptr) { if (interface == nullptr) {
return; return;
} }
interface->MAC_SetKeyboardMove(_keyboardMode, _move, _isDown); interface->MAC_SetKeyboardMove(_keyboardMode, _move, _isDown, _isAReapeateKey);
} }

View File

@ -22,7 +22,7 @@ namespace MacOs {
void setMouseState(int32_t _id, bool _isDown, float _x, float _y); void setMouseState(int32_t _id, bool _isDown, float _x, float _y);
void setMouseMotion(int32_t _id, float _x, float _y); void setMouseMotion(int32_t _id, float _x, float _y);
void setKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey); void setKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey);
void setKeyboardMove(ewol::key::Special& _keyboardMode, enum ewol::key::keyboard _move, bool _isDown); void setKeyboardMove(ewol::key::Special& _keyboardMode, enum ewol::key::keyboard _move, bool _isDown, bool _isAReapeateKey);
}; };
#endif #endif

View File

@ -50,7 +50,6 @@ int mm_main(int argc, const char *argv[]) {
// -- basic windows creation : // -- basic windows creation :
// ----------------------- ---------------------------------------- // ----------------------- ----------------------------------------
// create a windows of size 800/600 // create a windows of size 800/600
#if 1
id window = [ [ [EwolMainWindows alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600) id window = [ [ [EwolMainWindows alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
styleMask:(NSTitledWindowMask|NSMiniaturizableWindowMask|NSClosableWindowMask) backing:NSBackingStoreBuffered defer:NO] styleMask:(NSTitledWindowMask|NSMiniaturizableWindowMask|NSClosableWindowMask) backing:NSBackingStoreBuffered defer:NO]
autorelease]; autorelease];
@ -85,19 +84,6 @@ int mm_main(int argc, const char *argv[]) {
//[window makeKeyAndVisible]; //[window makeKeyAndVisible];
//[window setDelegate:view]; //[window setDelegate:view];
#else
@autoreleasepool
{
const ProcessSerialNumber psn = { 0, kCurrentProcess };
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
SetFrontProcess(&psn);
[MyApplication sharedApplication];
[NSApp setDelegate: NSApp];
[NSApp run];
}
#endif
// return no error // return no error
return 0; return 0;
} }

View File

@ -16,19 +16,4 @@
} }
- (void)prepareOpenGL; - (void)prepareOpenGL;
- (void)drawRect:(NSRect) bounds; - (void)drawRect:(NSRect) bounds;
- (void)mouseDown:(NSEvent *) event;
- (void)mouseDragged:(NSEvent *) event;
- (void)mouseUp:(NSEvent *)event;
- (void)mouseMoved:(NSEvent *)event;
- (void)mouseEntered:(NSEvent *)event;
- (void)mouseExited:(NSEvent *)event;
- (void)rightMouseDown:(NSEvent *)event;
- (void)rightMouseDragged:(NSEvent *)event;
- (void)rightMouseUp:(NSEvent *)event;
- (void)otherMouseDown:(NSEvent *)event;
- (void)otherMouseDragged:(NSEvent *)event;
- (void)otherMouseUp:(NSEvent *)event;
//- (void)sendEvent:(NSEvent *)event
- (void)keyDown:(NSEvent *)theEvent;
- (void)flagsChanged:(NSEvent *)theEvent;
@end @end

View File

@ -53,163 +53,13 @@
-(void)reshape { -(void)reshape {
EWOL_INFO("view reshape (" << [self frame].size.width << "," << [self frame].size.height << ")" ); EWOL_INFO("view reshape (" << [self frame].size.width << "," << [self frame].size.height << ")" );
// window resize; width and height are in pixel coordinates // window resize; width and height are in pixel coordinates
// but they are floats // but they are floats
float width = [self frame].size.width; float width = [self frame].size.width;
float height = [self frame].size.height; float height = [self frame].size.height;
MacOs::resize(width,height); MacOs::resize(width,height);
} }
-(void)mouseDown:(NSEvent *)event {
NSPoint point = [event locationInWindow];
//float x = [event locationInWindow].x; //point.x;
//EWOL_INFO("mouseDown : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseState(1, true, point.x, point.y);
}
-(void)mouseDragged:(NSEvent *)event {
NSPoint point = [event locationInWindow];
//EWOL_INFO("mouseDragged : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseMotion(1, point.x, point.y);
}
-(void)mouseUp:(NSEvent *)event {
NSPoint point = [event locationInWindow];
//EWOL_INFO("mouseUp : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseState(1, false, point.x, point.y);
}
-(void)mouseMoved:(NSEvent *)event {
NSPoint point = [event locationInWindow];
EWOL_INFO("mouseMoved : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseMotion(0, point.x, point.y);
}
-(void)mouseEntered:(NSEvent *)event {
NSPoint point = [event locationInWindow];
EWOL_INFO("mouseEntered : " << (float)point.x << " " << (float)point.y);
}
-(void)mouseExited:(NSEvent *)event {
NSPoint point = [event locationInWindow];
EWOL_INFO("mouseExited : " << (float)point.x << " " << (float)point.y);
}
-(void)rightMouseDown:(NSEvent *)event {
NSPoint point = [event locationInWindow];
//EWOL_INFO("rightMouseDown : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseState(3, true, point.x, point.y);
}
-(void)rightMouseDragged:(NSEvent *)event {
NSPoint point = [event locationInWindow];
//EWOL_INFO("rightMouseDragged : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseMotion(3, point.x, point.y);
}
-(void)rightMouseUp:(NSEvent *)event {
NSPoint point = [event locationInWindow];
//EWOL_INFO("rightMouseUp : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseState(3, false, point.x, point.y);
}
-(void)otherMouseDown:(NSEvent *)event {
NSPoint point = [event locationInWindow];
int32_t btNumber = [event buttonNumber];
switch (btNumber) {
case 2: // 2 : Middle button
btNumber = 2;
break;
case 3: // 3 : border button DOWN
btNumber = 8;
break;
case 4: // 4 : border button UP
btNumber = 9;
break;
case 5: // 5 : horizontal scroll Right to left
btNumber = 11;
break;
case 6: // 6 : horizontal scroll left to Right
btNumber = 10;
break;
case 7: // 7 : Red button
btNumber = 12;
break;
default:
btNumber = 15;
break;
}
//EWOL_INFO("otherMouseDown : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseState(btNumber, true, point.x, point.y);
}
-(void)otherMouseDragged:(NSEvent *)event {
NSPoint point = [event locationInWindow];
int32_t btNumber = [event buttonNumber];
switch (btNumber) {
case 2: // 2 : Middle button
btNumber = 2;
break;
case 3: // 3 : border button DOWN
btNumber = 8;
break;
case 4: // 4 : border button UP
btNumber = 9;
break;
case 5: // 5 : horizontal scroll Right to left
btNumber = 11;
break;
case 6: // 6 : horizontal scroll left to Right
btNumber = 10;
break;
case 7: // 7 : Red button
btNumber = 12;
break;
default:
btNumber = 15;
break;
}
//EWOL_INFO("otherMouseDragged : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseMotion(btNumber, point.x, point.y);
}
-(void)otherMouseUp:(NSEvent *)event {
NSPoint point = [event locationInWindow];
int32_t btNumber = [event buttonNumber];
switch (btNumber) {
case 2: // 2 : Middle button
btNumber = 2;
break;
case 3: // 3 : border button DOWN
btNumber = 8;
break;
case 4: // 4 : border button UP
btNumber = 9;
break;
case 5: // 5 : horizontal scroll Right to left
btNumber = 11;
break;
case 6: // 6 : horizontal scroll left to Right
btNumber = 10;
break;
case 7: // 7 : Red button
btNumber = 12;
break;
default:
btNumber = 15;
break;
}
//EWOL_INFO("otherMouseUp : " << (float)point.x << " " << (float)point.y << " bt id=" << btNumber );
MacOs::setMouseState(btNumber, false, point.x, point.y);
}
- (void)scrollWheel:(NSEvent *)event {
NSPoint point = [event locationInWindow];
//EWOL_INFO("scrollWheel : " << (float)point.x << " " << (float)point.y << "button : " << (int32_t)([event buttonNumber]));
EWOL_INFO("scrollWheel : " << (float)point.x << " " << (float)point.y << " delta(" << (float)([event deltaX]) << "," << (float)([event deltaY]) << ")");
float deltaY = [event deltaY];
int32_t idEvent = 4;
if (deltaY < 0) {
idEvent = 5;
}
if (abs(deltaY) < 0.1f) {
return;
}
for (float iii=abs(deltaY) ; iii>=0.0f ; iii-=1.0f) {
MacOs::setMouseState(idEvent, true , point.x, point.y);
MacOs::setMouseState(idEvent, false, point.x, point.y);
}
}
#define FRAME_INTERVAL (0.01) #define FRAME_INTERVAL (0.01)
static NSTimer *timer = nil; static NSTimer *timer = nil;

View File

@ -14,11 +14,23 @@
+ (id)alloc; + (id)alloc;
- (id)init; - (id)init;
+ (void)dealloc; + (void)dealloc;
+ (void)performClose:(id)sender;
// All mouse events:
- (void)mouseDown:(NSEvent *) event;
- (void)mouseDragged:(NSEvent *) event;
- (void)mouseUp:(NSEvent *)event;
- (void)mouseMoved:(NSEvent *)event;
- (void)mouseEntered:(NSEvent *)event;
- (void)mouseExited:(NSEvent *)event;
- (void)rightMouseDown:(NSEvent *)event;
- (void)rightMouseDragged:(NSEvent *)event;
- (void)rightMouseUp:(NSEvent *)event;
- (void)otherMouseDown:(NSEvent *)event;
- (void)otherMouseDragged:(NSEvent *)event;
- (void)otherMouseUp:(NSEvent *)event;
// keyboard eevnts:
- (void)keyDown:(NSEvent *)theEvent;
- (void)flagsChanged:(NSEvent *)theEvent;
@end @end
@interface MyApplication : NSApplication
@property (strong, nonatomic) NSWindow *window;
@end

View File

@ -73,143 +73,194 @@
[super dealloc]; [super dealloc];
} }
+ (void)performClose:(id)sender {
EWOL_DEBUG("perform close ...");
}
static ewol::key::Special guiKeyBoardMode; static ewol::key::Special guiKeyBoardMode;
static int32_t getUniChar(NSEvent* theEvent) { -(void)localKeyEvent:(NSEvent*)theEvent isDown:(bool)_isDown {
bool thisIsAReapeateKey = false;
if ([theEvent isARepeat]) {
thisIsAReapeateKey = true;
}
NSString *str = [theEvent charactersIgnoringModifiers]; NSString *str = [theEvent charactersIgnoringModifiers];
// TODO : set if for every char in the string !!! // TODO : set if for every char in the string !!!
unichar c = [str characterAtIndex:0]; unichar c = [str characterAtIndex:0];
if (guiKeyBoardMode.getAlt() == false) { EWOL_VERBOSE("Key Event " << c << " = '" << char(c) << "' isDown=" << _isDown);
return int32_t(c); bool find = true;
enum ewol::key::keyboard keyInput;
switch (c) {
case 63232: keyInput = ewol::key::keyboardUp; break;
case 63233: keyInput = ewol::key::keyboardDown; break;
case 63234: keyInput = ewol::key::keyboardLeft; break;
case 63235: keyInput = ewol::key::keyboardRight; break;
case 63276: keyInput = ewol::key::keyboardPageUp; break;
case 63277: keyInput = ewol::key::keyboardPageDown; break;
case 63273: keyInput = ewol::key::keyboardStart; break;
case 63275: keyInput = ewol::key::keyboardEnd; break;
/*
case 78: keyInput = ewol::key::keyboardStopDefil; break;
case 127: keyInput = ewol::key::keyboardWait; break;
*/
case 63302:
find = false;
keyInput = ewol::key::keyboardInsert;
if(_isDown == false) {
if (true == guiKeyBoardMode.getInsert()) {
guiKeyBoardMode.setInsert(false);
} else {
guiKeyBoardMode.setInsert(true);
}
}
EWOL_VERBOSE("Key Event " << c << " = '" << char(c) << "' isDown=" << _isDown);
MacOs::setKeyboardMove(guiKeyBoardMode, keyInput, true, thisIsAReapeateKey);
EWOL_VERBOSE("Key Event " << c << " = '" << char(c) << "' isDown=" << !_isDown);
MacOs::setKeyboardMove(guiKeyBoardMode, keyInput, false, thisIsAReapeateKey);
break;
//case 84: keyInput = ewol::key::keyboardCenter; break; // Keypad
case 63236: keyInput = ewol::key::keyboardF1; break;
case 63237: keyInput = ewol::key::keyboardF2; break;
case 63238: keyInput = ewol::key::keyboardF3; break;
case 63239: keyInput = ewol::key::keyboardF4; break;
case 63240: keyInput = ewol::key::keyboardF5; break;
case 63241: keyInput = ewol::key::keyboardF6; break;
case 63242: keyInput = ewol::key::keyboardF7; break;
case 63243: keyInput = ewol::key::keyboardF8; break;
case 63244: keyInput = ewol::key::keyboardF9; break;
case 63245: keyInput = ewol::key::keyboardF10; break;
case 63246: keyInput = ewol::key::keyboardF11; break;
case 63247: keyInput = ewol::key::keyboardF12; break;
case 63272: // Suppress
find = false;
MacOs::setKeyboard(guiKeyBoardMode, u32char::Delete, _isDown, thisIsAReapeateKey);
if (true == thisIsAReapeateKey) {
MacOs::setKeyboard(guiKeyBoardMode, u32char::Delete, !_isDown, thisIsAReapeateKey);
}
break;
default:
find = false;
{
if (guiKeyBoardMode.getAlt() == true) {
// special keyboard transcription ...
str = [theEvent characters];
c = [str characterAtIndex:0];
}
EWOL_VERBOSE("Key Event " << c << " = '" << char(c) << "' isDown=" << _isDown);
MacOs::setKeyboard(guiKeyBoardMode, c, _isDown, thisIsAReapeateKey);
if (true==thisIsAReapeateKey) {
MacOs::setKeyboard(guiKeyBoardMode, c, !_isDown, thisIsAReapeateKey);
}
}
break;
} }
switch(c) { if (find == true) {
case '(': EWOL_VERBOSE("eventKey Move type : " << keyInput );
return int32_t('{'); MacOs::setKeyboardMove(guiKeyBoardMode, keyInput, _isDown, thisIsAReapeateKey);
case '5': if (true == thisIsAReapeateKey) {
return int32_t('['); MacOs::setKeyboardMove(guiKeyBoardMode, keyInput, !_isDown, thisIsAReapeateKey);
case ')': }
return int32_t('}');
case U'°':
return int32_t(']');
} }
return int32_t(c);
} }
- (void)keyDown:(NSEvent *)theEvent { - (void)keyDown:(NSEvent *)theEvent {
bool thisIsAReapeateKey = false; [self localKeyEvent:theEvent isDown:true];
if ([theEvent isARepeat]) {
thisIsAReapeateKey = true;
}
int32_t c = getUniChar(theEvent);
EWOL_WARNING("KeyDown " << char(c));
MacOs::setKeyboard(guiKeyBoardMode, c, true, thisIsAReapeateKey);
if (true==thisIsAReapeateKey) {
MacOs::setKeyboard(guiKeyBoardMode, c, false, thisIsAReapeateKey);
}
} }
- (void)keyUp:(NSEvent *)theEvent { - (void)keyUp:(NSEvent *)theEvent {
bool thisIsAReapeateKey = false; [self localKeyEvent:theEvent isDown:false];
if ([theEvent isARepeat]) {
thisIsAReapeateKey = true;
}
int32_t c = getUniChar(theEvent);
EWOL_WARNING("KeyUp " << char(c));
MacOs::setKeyboard(guiKeyBoardMode, c, false, thisIsAReapeateKey);
if (true==thisIsAReapeateKey) {
MacOs::setKeyboard(guiKeyBoardMode, c, true, thisIsAReapeateKey);
}
} }
- (void)flagsChanged:(NSEvent *)theEvent { - (void)flagsChanged:(NSEvent *)theEvent {
if (([theEvent modifierFlags] & NSAlphaShiftKeyMask) != 0) { if (([theEvent modifierFlags] & NSAlphaShiftKeyMask) != 0) {
EWOL_WARNING("NSAlphaShiftKeyMask"); EWOL_VERBOSE("NSAlphaShiftKeyMask");
if (guiKeyBoardMode.getCapsLock() == false) { if (guiKeyBoardMode.getCapsLock() == false) {
guiKeyBoardMode.setCapsLock(true); guiKeyBoardMode.setCapsLock(true);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardCapLock, true); MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardCapLock, true, false);
} }
} else { } else {
if (guiKeyBoardMode.getCapsLock() == true) { if (guiKeyBoardMode.getCapsLock() == true) {
guiKeyBoardMode.setCapsLock(false); guiKeyBoardMode.setCapsLock(false);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardCapLock, false); MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardCapLock, false, false);
} }
} }
if (([theEvent modifierFlags] & NSShiftKeyMask) != 0) { if (([theEvent modifierFlags] & NSShiftKeyMask) != 0) {
EWOL_WARNING("NSShiftKeyMask"); EWOL_VERBOSE("NSShiftKeyMask");
if (guiKeyBoardMode.getShift() == false) { if (guiKeyBoardMode.getShift() == false) {
guiKeyBoardMode.setShift(true); guiKeyBoardMode.setShift(true);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardShiftLeft, true); MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardShiftLeft, true, false);
} }
} else { } else {
if (guiKeyBoardMode.getShift() == true) { if (guiKeyBoardMode.getShift() == true) {
guiKeyBoardMode.setShift(false); guiKeyBoardMode.setShift(false);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardShiftLeft, false); MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardShiftLeft, false, false);
} }
} }
if (([theEvent modifierFlags] & NSControlKeyMask) != 0) { if (([theEvent modifierFlags] & NSControlKeyMask) != 0) {
EWOL_WARNING("NSControlKeyMask"); EWOL_VERBOSE("NSControlKeyMask");
if (guiKeyBoardMode.getCtrl() == false) { if (guiKeyBoardMode.getCtrl() == false) {
guiKeyBoardMode.setCtrl(true); guiKeyBoardMode.setCtrl(true);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardCtrlLeft, true); MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardCtrlLeft, true, false);
} }
} else { } else {
if (guiKeyBoardMode.getCtrl() == true) { if (guiKeyBoardMode.getCtrl() == true) {
guiKeyBoardMode.setCtrl(false); guiKeyBoardMode.setCtrl(false);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardCtrlLeft, false); MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardCtrlLeft, false, false);
} }
} }
if (([theEvent modifierFlags] & NSAlternateKeyMask) != 0) { if (([theEvent modifierFlags] & NSAlternateKeyMask) != 0) {
EWOL_WARNING("NSAlternateKeyMask"); EWOL_VERBOSE("NSAlternateKeyMask");
if (guiKeyBoardMode.getAlt() == false) { if (guiKeyBoardMode.getAlt() == false) {
guiKeyBoardMode.setAlt(true); guiKeyBoardMode.setAlt(true);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardAlt, true); MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardAlt, true, false);
} }
} else { } else {
if (guiKeyBoardMode.getAlt() == true) { if (guiKeyBoardMode.getAlt() == true) {
guiKeyBoardMode.setAlt(false); guiKeyBoardMode.setAlt(false);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardAlt, false); MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardAlt, false, false);
} }
} }
if (([theEvent modifierFlags] & NSCommandKeyMask) != 0) { if (([theEvent modifierFlags] & NSCommandKeyMask) != 0) {
EWOL_WARNING("NSCommandKeyMask"); EWOL_VERBOSE("NSCommandKeyMask");
if (guiKeyBoardMode.getMeta() == false) { if (guiKeyBoardMode.getMeta() == false) {
guiKeyBoardMode.setMeta(true); guiKeyBoardMode.setMeta(true);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardMetaLeft, true); MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardMetaLeft, true, false);
} }
} else { } else {
if (guiKeyBoardMode.getMeta() == true) { if (guiKeyBoardMode.getMeta() == true) {
guiKeyBoardMode.setMeta(false); guiKeyBoardMode.setMeta(false);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardMetaLeft, false); MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardMetaLeft, false, false);
} }
} }
if (([theEvent modifierFlags] & NSNumericPadKeyMask) != 0) { if (([theEvent modifierFlags] & NSNumericPadKeyMask) != 0) {
EWOL_WARNING("NSNumericPadKeyMask"); EWOL_VERBOSE("NSNumericPadKeyMask");
if (guiKeyBoardMode.getNumLock() == false) { if (guiKeyBoardMode.getNumLock() == false) {
guiKeyBoardMode.setNumLock(true); guiKeyBoardMode.setNumLock(true);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardNumLock, true); MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardNumLock, true, false);
} }
} else { } else {
if (guiKeyBoardMode.getNumLock() == true) { if (guiKeyBoardMode.getNumLock() == true) {
guiKeyBoardMode.setNumLock(false); guiKeyBoardMode.setNumLock(false);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardNumLock, false); MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardNumLock, false, false);
} }
} }
if (([theEvent modifierFlags] & NSHelpKeyMask) != 0) { if (([theEvent modifierFlags] & NSHelpKeyMask) != 0) {
EWOL_WARNING("NSHelpKeyMask"); EWOL_VERBOSE("NSHelpKeyMask");
} }
if (([theEvent modifierFlags] & NSFunctionKeyMask) != 0) { if (([theEvent modifierFlags] & NSFunctionKeyMask) != 0) {
EWOL_WARNING("NSFunctionKeyMask"); EWOL_VERBOSE("NSFunctionKeyMask");
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardContextMenu, true); MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardContextMenu, true, false);
MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardContextMenu, false); MacOs::setKeyboardMove(guiKeyBoardMode, ewol::key::keyboardContextMenu, false, false);
} }
EWOL_WARNING("EVENT : " << int32_t([theEvent modifierFlags])); EWOL_VERBOSE("EVENT : " << int32_t([theEvent modifierFlags]));
} }
// this generate all the event entry availlable ==> like a big keep focus ... // this generate all the event entry availlable ==> like a big keep focus ...
@ -222,7 +273,7 @@ static int32_t getUniChar(NSEvent* theEvent) {
-(void)mouseMoved:(NSEvent *)event { -(void)mouseMoved:(NSEvent *)event {
NSPoint point = [event locationInWindow]; NSPoint point = [event locationInWindow];
EWOL_INFO("mouseMoved : " << (float)point.x << " " << (float)point.y); EWOL_VERBOSE("mouseMoved : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseMotion(0, point.x, point.y); MacOs::setMouseMotion(0, point.x, point.y);
} }
-(void)mouseEntered:(NSEvent *)event { -(void)mouseEntered:(NSEvent *)event {
@ -234,28 +285,143 @@ static int32_t getUniChar(NSEvent* theEvent) {
EWOL_INFO("mouseExited : " << (float)point.x << " " << (float)point.y); EWOL_INFO("mouseExited : " << (float)point.x << " " << (float)point.y);
} }
-(void)mouseDown:(NSEvent *)event {
NSPoint point = [event locationInWindow];
EWOL_VERBOSE("mouseDown : " << (float)point.x << " " << (float)point.y);
@end MacOs::setMouseState(1, true, point.x, point.y);
}
-(void)mouseDragged:(NSEvent *)event {
NSPoint point = [event locationInWindow];
EWOL_VERBOSE("mouseDragged : " << (float)point.x << " " << (float)point.y);
@implementation MyApplication MacOs::setMouseMotion(1, point.x, point.y);
}
- (void) applicationDidFinishLaunching: (NSNotification *) note -(void)mouseUp:(NSEvent *)event {
{ NSPoint point = [event locationInWindow];
NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect(100, 100, 100, 100) EWOL_VERBOSE("mouseUp : " << (float)point.x << " " << (float)point.y);
styleMask:NSTitledWindowMask backing:NSBackingStoreBuffered defer:YES]; MacOs::setMouseState(1, false, point.x, point.y);
}
self.window = window; -(void)rightMouseDown:(NSEvent *)event {
NSPoint point = [event locationInWindow];
[window close]; EWOL_VERBOSE("rightMouseDown : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseState(3, true, point.x, point.y);
[super stop: self]; }
-(void)rightMouseDragged:(NSEvent *)event {
NSPoint point = [event locationInWindow];
EWOL_VERBOSE("rightMouseDragged : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseMotion(3, point.x, point.y);
}
-(void)rightMouseUp:(NSEvent *)event {
NSPoint point = [event locationInWindow];
EWOL_VERBOSE("rightMouseUp : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseState(3, false, point.x, point.y);
}
-(void)otherMouseDown:(NSEvent *)event {
NSPoint point = [event locationInWindow];
int32_t btNumber = [event buttonNumber];
switch (btNumber) {
case 2: // 2 : Middle button
btNumber = 2;
break;
case 3: // 3 : border button DOWN
btNumber = 8;
break;
case 4: // 4 : border button UP
btNumber = 9;
break;
case 5: // 5 : horizontal scroll Right to left
btNumber = 11;
break;
case 6: // 6 : horizontal scroll left to Right
btNumber = 10;
break;
case 7: // 7 : Red button
btNumber = 12;
break;
default:
btNumber = 15;
break;
}
EWOL_VERBOSE("otherMouseDown : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseState(btNumber, true, point.x, point.y);
}
-(void)otherMouseDragged:(NSEvent *)event {
NSPoint point = [event locationInWindow];
int32_t btNumber = [event buttonNumber];
switch (btNumber) {
case 2: // 2 : Middle button
btNumber = 2;
break;
case 3: // 3 : border button DOWN
btNumber = 8;
break;
case 4: // 4 : border button UP
btNumber = 9;
break;
case 5: // 5 : horizontal scroll Right to left
btNumber = 11;
break;
case 6: // 6 : horizontal scroll left to Right
btNumber = 10;
break;
case 7: // 7 : Red button
btNumber = 12;
break;
default:
btNumber = 15;
break;
}
EWOL_VERBOSE("otherMouseDragged : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseMotion(btNumber, point.x, point.y);
}
-(void)otherMouseUp:(NSEvent *)event {
NSPoint point = [event locationInWindow];
int32_t btNumber = [event buttonNumber];
EWOL_VERBOSE("otherMouseUp: id=" << btNumber );
switch (btNumber) {
case 2: // 2 : Middle button
btNumber = 2;
break;
case 3: // 3 : border button DOWN
btNumber = 8;
break;
case 4: // 4 : border button UP
btNumber = 9;
break;
case 5: // 5 : horizontal scroll Right to left
btNumber = 11;
break;
case 6: // 6 : horizontal scroll left to Right
btNumber = 10;
break;
case 7: // 7 : Red button
btNumber = 12;
break;
default:
btNumber = 15;
break;
}
EWOL_VERBOSE("otherMouseUp : " << (float)point.x << " " << (float)point.y << " bt id=" << btNumber );
MacOs::setMouseState(btNumber, false, point.x, point.y);
}
- (void)scrollWheel:(NSEvent *)event {
NSPoint point = [event locationInWindow];
EWOL_VERBOSE("scrollWheel : " << (float)point.x << " " << (float)point.y << " delta(" << (float)([event deltaX]) << "," << (float)([event deltaY]) << ")");
float deltaY = [event deltaY];
int32_t idEvent = 4;
if (deltaY < 0) {
idEvent = 5;
}
if (fabs(deltaY) < 0.1f) {
return;
}
for (float iii=fabs(deltaY) ; iii>=0.0f ; iii-=1.0f) {
MacOs::setMouseState(idEvent, true , point.x, point.y);
MacOs::setMouseState(idEvent, false, point.x, point.y);
}
} }
@end @end