comparison mac/dw.m @ 701:c91a1b345f2e

Fix for button press and context menus.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 11 Mar 2011 05:23:17 +0000
parents 7953f0471e4d
children e9a3d1da3d3e
comparison
equal deleted inserted replaced
700:7953f0471e4d 701:c91a1b345f2e
139 } 139 }
140 case 3: 140 case 3:
141 case 4: 141 case 4:
142 { 142 {
143 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; 143 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction;
144 int flags = (int)[object pressedMouseButtons]; 144 int button = (int)event;
145 NSPoint point = [object mouseLocation]; 145 LONG x,y;
146 int button = 0; 146
147 147 dw_pointer_query_pos(&x, &y);
148 if(flags & 1) 148
149 { 149 return buttonfunc(object, (int)x, (int)y, button, handler->data);
150 button = 1;
151 }
152 else if(flags & (1 << 1))
153 {
154 button = 2;
155 }
156 else if(flags & (1 << 2))
157 {
158 button = 3;
159 }
160
161 return buttonfunc(object, point.x, point.y, button, handler->data);
162 } 150 }
163 case 6: 151 case 6:
164 { 152 {
165 int (* API closefunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; 153 int (* API closefunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction;
166 return closefunc(object, handler->data); 154 return closefunc(object, handler->data);
330 -(void)setUserdata:(void *)input; 318 -(void)setUserdata:(void *)input;
331 -(void)drawRect:(NSRect)rect; 319 -(void)drawRect:(NSRect)rect;
332 -(BOOL)isFlipped; 320 -(BOOL)isFlipped;
333 -(void)mouseDown:(NSEvent *)theEvent; 321 -(void)mouseDown:(NSEvent *)theEvent;
334 -(void)mouseUp:(NSEvent *)theEvent; 322 -(void)mouseUp:(NSEvent *)theEvent;
323 -(NSMenu *)menuForEvent:(NSEvent *)theEvent;
324 -(void)rightMouseUp:(NSEvent *)theEvent;
325 -(void)otherMouseDown:(NSEvent *)theEvent;
326 -(void)otherMouseUp:(NSEvent *)theEvent;
335 -(void)setColor:(unsigned long)input; 327 -(void)setColor:(unsigned long)input;
336 @end 328 @end
337 329
338 @implementation DWBox 330 @implementation DWBox
339 -(id)init 331 -(id)init
363 [bgcolor set]; 355 [bgcolor set];
364 NSRectFill( [self bounds] ); 356 NSRectFill( [self bounds] );
365 } 357 }
366 } 358 }
367 -(BOOL)isFlipped { return YES; } 359 -(BOOL)isFlipped { return YES; }
368 -(void)mouseDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 3); } 360 -(void)mouseDown:(NSEvent *)theEvent { _event_handler(self, (void *)1, 3); }
369 -(void)mouseUp:(NSEvent *)theEvent { _event_handler(self, theEvent, 4); } 361 -(void)mouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)1, 4); }
362 -(NSMenu *)menuForEvent:(NSEvent *)theEvent { _event_handler(self, (void *)2, 3); return nil; }
363 -(void)rightMouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)2, 4); }
364 -(void)otherMouseDown:(NSEvent *)theEvent { _event_handler(self, (void *)3, 3); }
365 -(void)otherMouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)3, 4); }
370 -(void)setColor:(unsigned long)input 366 -(void)setColor:(unsigned long)input
371 { 367 {
372 if(input == _colors[DW_CLR_DEFAULT]) 368 if(input == _colors[DW_CLR_DEFAULT])
373 { 369 {
374 bgcolor = nil; 370 bgcolor = nil;
644 { 640 {
645 void *userdata; 641 void *userdata;
646 } 642 }
647 -(void *)userdata; 643 -(void *)userdata;
648 -(void)setUserdata:(void *)input; 644 -(void)setUserdata:(void *)input;
649 -(void)drawRect:(NSRect)rect;
650 -(void)mouseDown:(NSEvent *)theEvent; 645 -(void)mouseDown:(NSEvent *)theEvent;
651 -(void)mouseUp:(NSEvent *)theEvent; 646 -(void)mouseUp:(NSEvent *)theEvent;
647 -(NSMenu *)menuForEvent:(NSEvent *)theEvent;
648 -(void)rightMouseUp:(NSEvent *)theEvent;
649 -(void)otherMouseDown:(NSEvent *)theEvent;
650 -(void)otherMouseUp:(NSEvent *)theEvent;
651 -(void)drawRect:(NSRect)rect;
652 -(BOOL)isFlipped; 652 -(BOOL)isFlipped;
653 @end 653 @end
654 654
655 @implementation DWRender 655 @implementation DWRender
656 -(void *)userdata { return userdata; } 656 -(void *)userdata { return userdata; }
657 -(void)setUserdata:(void *)input { userdata = input; } 657 -(void)setUserdata:(void *)input { userdata = input; }
658 -(void)mouseDown:(NSEvent *)theEvent { _event_handler(self, (void *)1, 3); }
659 -(void)mouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)1, 4); }
660 -(NSMenu *)menuForEvent:(NSEvent *)theEvent { _event_handler(self, (void *)2, 3); return nil; }
661 -(void)rightMouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)2, 4); }
662 -(void)otherMouseDown:(NSEvent *)theEvent { _event_handler(self, (void *)3, 3); }
663 -(void)otherMouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)3, 4); }
658 -(void)drawRect:(NSRect)rect { _event_handler(self, nil, 7); } 664 -(void)drawRect:(NSRect)rect { _event_handler(self, nil, 7); }
659 -(void)mouseDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 3); }
660 -(void)mouseUp:(NSEvent *)theEvent { _event_handler(self, theEvent, 4); }
661 -(BOOL)isFlipped { return NO; } 665 -(BOOL)isFlipped { return NO; }
662 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } 666 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; }
663 @end 667 @end
664 668
665 /* Subclass for a MLE type */ 669 /* Subclass for a MLE type */
4951 * x: X coordinate. 4955 * x: X coordinate.
4952 * y: Y coordinate. 4956 * y: Y coordinate.
4953 */ 4957 */
4954 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) 4958 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y)
4955 { 4959 {
4956 NSMenu *thismenu = (NSMenu *)menu; 4960 NSMenu *thismenu = (NSMenu *)*menu;
4957 NSView *view = parent; 4961 NSView *view = parent;
4958 NSEvent* fake = [[NSEvent alloc] 4962 NSEvent *event = [DWApp currentEvent];
4959 mouseEventWithType:NSLeftMouseDown 4963 [NSMenu popUpContextMenu:thismenu withEvent:event forView:view];
4960 location:NSMakePoint(x,y)
4961 modifierFlags:0
4962 timestamp:1
4963 windowNumber:[[view window] windowNumber]
4964 context:[NSGraphicsContext currentContext]
4965 eventNumber:1
4966 clickCount:1
4967 pressure:0.0];
4968 [NSMenu popUpContextMenu:thismenu withEvent:fake forView:view];
4969 } 4964 }
4970 4965
4971 char _removetilde(char *dest, char *src) 4966 char _removetilde(char *dest, char *src)
4972 { 4967 {
4973 int z, cur=0; 4968 int z, cur=0;