|
|
Re: Embedding custom cocoa widgets in SWT [message #521407 is a reply to message #520523] |
Wed, 17 March 2010 14:18 |
Artem Redkin Messages: 26 Registered: July 2009 |
Junior Member |
|
|
Grant Gayed wrote on Fri, 12 March 2010 12:47 | SWT currently sets the cell in Display.initClasses() (search for string
"SWTTextField") by calling NSTextField.setCellClass(...). So you need to do this too, but this will remove the accessibility callbacks that swt's custom cell was hooking. Perhaps the best approach is for you to create a Text control, get its cell (this will be the SWT-provided cell), and make your cell class a subclass of the SWT cell's class. Then you should be able to call NSTextField.setCellClass(...) with your class and still preserve the SWT cell's accessibility hooks.
|
Thank for your answer, Grant! I was able to substitute NSTextField's cell with my own, but other questions emerged.
If i call setCellClass, all my instances of Text will use my cell, right? I need both types of cell simultaneously, more precise i want new control, that is subclass of Text, that uses my cell. Maybe i should sublcass NSTextField and call setCellClass on it?
I also can't understand, how to call obj-c method through jni. I have function:
JNIEXPORT jint JNICALL Java_org_cargosoft_internal_LibDFCell_setButtonWidth(JNIEnv *env, jobject arg0, jfloat arg1) {
DefaultReferenceCell *cell = (DefaultReferenceCell*)arg0;
[cell setButtonsWidth:(float)arg1];
return 0;
}
from java i call it like that:
LibDFCell.setButtonWidth(widget.cell, 10);
With that i get:
Invalid memory access of location 0x3800000010 rip=0x7fff884ea13e
How can i pass pointer to cell to jni/obj-c (sorry, i'm not very experienced with jni)?
|
|
|
Re: Embedding custom cocoa widgets in SWT [message #522301 is a reply to message #521407] |
Mon, 22 March 2010 08:27 |
Artem Redkin Messages: 26 Registered: July 2009 |
Junior Member |
|
|
Artem Redkin wrote on Wed, 17 March 2010 10:18 | I also can't understand, how to call obj-c method through jni. I have function:
JNIEXPORT jint JNICALL Java_org_cargosoft_internal_LibDFCell_setButtonWidth(JNIEnv *env, jobject arg0, jfloat arg1) {
DefaultReferenceCell *cell = (DefaultReferenceCell*)arg0;
[cell setButtonsWidth:(float)arg1];
return 0;
}
| That was a bit stupid bit of code . I was able to do it in java:
long selector = OS.sel_registerName("setButtonsWidth:");
OS.objc_msgSend(widget.cell().id, selector, 10);
But I want to know how to make objc/jni work. I rewrote jni code:
JNIEXPORT jlong JNICALL Java_org_cargosoft_internal_LibDFCell_setButtonWidth(JNIEnv *env, jlong arg0, jfloat arg1) {
jlong rc = 0;
SEL selector = sel_registerName("setButtonsWidth:");
rc = (jlong)objc_msgSend((id)arg0, selector, (float)arg1);
return rc;
}
This gives me Invalid memory access of location 0x3800000010 rip=0x7fff884ea13e.
[Updated on: Mon, 22 March 2010 10:54] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.02802 seconds