On Wed, 2010-02-10 at 08:39 -0200, Douglaz wrote:
> Hello!
>
> I just got my hands in the java-gnome v.4.0.14 'News' file
You mean http://java-gnome.sourceforge.net/4.0/NEWS.html#4.0.14 :)
> and found something really interesting for me, regarding the GTK
> Input Handling.
Sure. So that's
http://java-gnome.sourceforge.net/4.0/doc/api/org/gnome/gtk/InputMethod.html
for people who haven't seen it. Which is to say, there's not much there,
sorry. Perhaps someone can improve it.
> However I could not find a good tutorial about how to use this as
> intended.
Did you see:
http://java-gnome.sourceforge.net/4.0/doc/api/org/gnome/gtk/InputMethod.html#filterKeypress(org.gnome.gdk.EventKey)
Failing that, I can show you the code I happen to be working that needed
this and led me to add coverage for it to java-gnome. But in brief, for
DrawingArea d and InputMethod im,
im = new SimpleInputMethod();
...
d.connect(new Widget.KeyPressEvent() {
public boolean onKeyPressEvent(Widget source, EventKey event) {
if (im.filterKeypress(event)) {
return true;
}
return false;
}
});
d.connect(new Widget.KeyReleaseEvent() {
public boolean onKeyReleaseEvent(Widget source, EventKey event) {
if (im.filterKeypress(event)) {
return true;
}
return false;
}
});
im.connect(new InputMethod.Commit() {
public void onCommit(InputMethod source, String str) {
doSomethingWith(str);
}
});
which is from tests/prototype/ManualInput.java, where I first
experimented with all this.
Incidentally, even mere westerners like me we can still see some of the
fancy pre-edit stuff [in normal text entry, say in gedit] by hitting
Crtl+Shift+U and then typing a 2-5 digit Unicode codepoint number. I
think there are a few more signals needed if we want to emulate that
ourselves (it still works, but to display pre-edit we have to draw your
own pre-edit strings apparently. Reading the code in GTK's
gtk/gtktextview.c is illuminating if you can manage it). I tried to get
a real input method (Japanese, say) on board but was a bit lost so can't
say 100% if that's working right [but if they draw their own preedits,
then I hope so].
AfC
Sydney
--
Andrew Frederick Cowie
http://www.andrewcowie.com/
|