summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--area_darwin.go22
-rw-r--r--bleh_darwin.m17
-rw-r--r--objc_darwin.h6
3 files changed, 32 insertions, 13 deletions
diff --git a/area_darwin.go b/area_darwin.go
index afb5b12..3261a7b 100644
--- a/area_darwin.go
+++ b/area_darwin.go
@@ -245,45 +245,45 @@ var (
_keyCode = sel_getUid("keyCode")
)
-func handleKeyEvent(self C.id) {
- // TODO
+func handleKeyEvent(self C.id, SEL C.SEL, e C.id) {
+ C.objc_msgSendSuper_id(self, _NSView, SEL, e)
}
-func sendKeyEvent(self C.id, ke KeyEvent) {
+func sendKeyEvent(self C.id, sel C.SEL, e C.id, ke KeyEvent) {
s := getSysData(self)
handled, repaint := s.handler.Key(ke)
if repaint {
C.objc_msgSend_noargs(self, _display)
}
if !handled {
- handleKeyEvent(self)
+ handleKeyEvent(self, sel, e)
}
}
-func areaKeyEvent(self C.id, e C.id, up bool) {
+func areaKeyEvent(self C.id, sel C.SEL, e C.id, up bool) {
var ke KeyEvent
keyCode := uintptr(C.objc_msgSend_ushortret_noargs(e, _keyCode))
ke, ok := fromKeycode(keyCode)
if !ok {
// no such key; modifiers by themselves are handled by -[self flagsChanged:]
- handleKeyEvent(self)
+ handleKeyEvent(self, sel, e)
return
}
// either ke.Key or ke.ExtKey will be set at this point
ke.Modifiers = parseModifiers(e)
ke.Up = up
- sendKeyEvent(self, ke)
+ sendKeyEvent(self, sel, e, ke)
}
//export areaView_keyDown
func areaView_keyDown(self C.id, sel C.SEL, e C.id) {
- areaKeyEvent(self, e, false)
+ areaKeyEvent(self, sel, e, false)
}
//export areaView_keyUp
func areaView_keyUp(self C.id, sel C.SEL, e C.id) {
- areaKeyEvent(self, e, true)
+ areaKeyEvent(self, sel, e, true)
}
//export areaView_flagsChanged
@@ -295,10 +295,10 @@ func areaView_flagsChanged(self C.id, sel C.SEL, e C.id) {
keyCode := uintptr(C.objc_msgSend_ushortret_noargs(e, _keyCode))
mod, ok := keycodeModifiers[keyCode] // comma-ok form to avoid adding entries
if !ok { // unknown modifier; ignore
- handleKeyEvent(self)
+ handleKeyEvent(self, sel, e)
return
}
ke.Modifiers = parseModifiers(e)
ke.Up = (ke.Modifiers & mod) == 0
- sendKeyEvent(self, ke)
+ sendKeyEvent(self, sel, e, ke)
}
diff --git a/bleh_darwin.m b/bleh_darwin.m
index 330bc20..bda237a 100644
--- a/bleh_darwin.m
+++ b/bleh_darwin.m
@@ -358,3 +358,20 @@ id makeTrackingArea(id area)
nil); /* userData: */
return trackingArea;
}
+
+/*
+Objective-C 1.0 has the class field of struct objc_super field as class
+Objective-C 2.0 has it as super_class
+and objc_darwin.h is compiled by both C and Objective-C code
+man isn't t his fun?!
+also this made me realize all my problems with working w ith the Objective-C runtime is because Apple's docs haven't been updated to the Objective-C 2.0 stuff so I'm assuming I'll have to read the header files for documentation instead of that
+*/
+
+id objc_msgSendSuper_id(id obj, id class, SEL sel, id a)
+{
+ struct objc_super s;
+
+ s.receiver = obj;
+ s.super_class = (Class) class;
+ return objc_msgSendSuper(&s, sel, a);
+}
diff --git a/objc_darwin.h b/objc_darwin.h
index d86131c..d5211ea 100644
--- a/objc_darwin.h
+++ b/objc_darwin.h
@@ -54,7 +54,7 @@ extern uintptr_t objc_msgSend_uintret_uint(id obj, SEL sel, uintptr_t a);
extern intptr_t objc_msgSend_intret_noargs(id obj, SEL sel);
-extern uintptr_t objc_msgSend_ushortret_noargs(id objc, SEL sel);
+extern uintptr_t objc_msgSend_ushortret_noargs(id obj, SEL sel);
#define m1(name, type1) \
static inline id objc_msgSend_ ## name (id obj, SEL sel, type1 a) \
@@ -90,7 +90,9 @@ m1(bool, BOOL)
extern id objc_msgSend_int(id obj, SEL sel, intptr_t a);
m1(double, double)
extern id objc_msgSend_point(id obj, SEL sel, int64_t x, int64_t y);
-extern id objc_msgSend_size(id objc, SEL sel, int64_t width, int64_t height);
+extern id objc_msgSend_size(id obj, SEL sel, int64_t width, int64_t height);
+
+extern id objc_msgSendSuper_id(id obj, id class, SEL sel, id a);
m2(id_id, id, id)
extern id objc_msgSend_rect_bool(id obj, SEL sel, int64_t x, int64_t y, int64_t w, int64_t h, BOOL b);