comparison mac/dw.m @ 922:07f9a73c6847

Fix for button press/release events coordinates being relative to the window instead of the screen on Mac.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 22 Apr 2011 11:01:25 +0000
parents 4c9bef883b14
children 0ac67b62b594
comparison
equal deleted inserted replaced
921:4c9bef883b14 922:07f9a73c6847
219 /* Button press and release event */ 219 /* Button press and release event */
220 case 3: 220 case 3:
221 case 4: 221 case 4:
222 { 222 {
223 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; 223 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction;
224 int button = (int)event; 224 NSPoint p = [object convertPoint:[event locationInWindow] fromView:nil];
225 LONG x,y; 225 NSEventType type = [event type];
226 226 int button = 1;
227 dw_pointer_query_pos(&x, &y); 227
228 228 if(type == NSRightMouseDown || type == NSRightMouseUp)
229 return buttonfunc(object, (int)x, (int)y, button, handler->data); 229 {
230 button = 2;
231 }
232 else if(type == NSOtherMouseDown || type == NSOtherMouseUp)
233 {
234 button = 3;
235 }
236
237 return buttonfunc(object, (int)p.x, (int)[object frame].size.height - p.y, button, handler->data);
230 } 238 }
231 /* Motion notify event */ 239 /* Motion notify event */
232 case 5: 240 case 5:
233 { 241 {
234 int (* API motionfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; 242 int (* API motionfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction;
1145 -(void)setUserdata:(void *)input { userdata = input; } 1153 -(void)setUserdata:(void *)input { userdata = input; }
1146 -(void)setFont:(NSFont *)input { [font release]; font = input; [font retain]; } 1154 -(void)setFont:(NSFont *)input { [font release]; font = input; [font retain]; }
1147 -(NSFont *)font { return font; } 1155 -(NSFont *)font { return font; }
1148 -(void)setSize:(NSSize)input { size = input; } 1156 -(void)setSize:(NSSize)input { size = input; }
1149 -(NSSize)size { return size; } 1157 -(NSSize)size { return size; }
1150 -(void)mouseDown:(NSEvent *)theEvent { _event_handler(self, (void *)1, 3); } 1158 -(void)mouseDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 3); }
1151 -(void)mouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)1, 4); } 1159 -(void)mouseUp:(NSEvent *)theEvent { _event_handler(self, theEvent, 4); }
1152 -(NSMenu *)menuForEvent:(NSEvent *)theEvent { _event_handler(self, (void *)2, 3); return nil; } 1160 -(NSMenu *)menuForEvent:(NSEvent *)theEvent { _event_handler(self, theEvent, 3); return nil; }
1153 -(void)rightMouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)2, 4); } 1161 -(void)rightMouseUp:(NSEvent *)theEvent { _event_handler(self, theEvent, 4); }
1154 -(void)otherMouseDown:(NSEvent *)theEvent { _event_handler(self, (void *)3, 3); } 1162 -(void)otherMouseDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 3); }
1155 -(void)otherMouseUp:(NSEvent *)theEvent { _event_handler(self, (void *)3, 4); } 1163 -(void)otherMouseUp:(NSEvent *)theEvent { _event_handler(self, theEvent, 4); }
1156 -(void)drawRect:(NSRect)rect { _event_handler(self, nil, 7); } 1164 -(void)drawRect:(NSRect)rect { _event_handler(self, nil, 7); }
1157 -(void)keyDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 2); } 1165 -(void)keyDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 2); }
1158 -(BOOL)isFlipped { return NO; } 1166 -(BOOL)isFlipped { return NO; }
1159 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [font release]; [super dealloc]; } 1167 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [font release]; [super dealloc]; }
1160 @end 1168 @end
4360 * A handle to the widget or NULL on failure. 4368 * A handle to the widget or NULL on failure.
4361 */ 4369 */
4362 HWND API dw_render_new(unsigned long cid) 4370 HWND API dw_render_new(unsigned long cid)
4363 { 4371 {
4364 DWRender *render = [[DWRender alloc] init]; 4372 DWRender *render = [[DWRender alloc] init];
4365 /* [render setTag:cid]; Why doesn't this work? */ 4373 [render setTag:cid];
4366 return render; 4374 return render;
4367 } 4375 }
4368 4376
4369 /* Sets the current foreground drawing color. 4377 /* Sets the current foreground drawing color.
4370 * Parameters: 4378 * Parameters: