# Help for GTK API Calling

**URL:** <https://forum.xojo.com/t/help-for-gtk-api-calling/13441>\
**Category:** Linux\
**Created:** [January 6, 2014, 3:23am UTC](https://forum.xojo.com/t/help-for-gtk-api-calling/13441 "2014-01-06T03:23:45Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![EShen\_Shiou](https://forum.xojo.com/user_avatar/forum.xojo.com/eshen_shiou/32/7645_2.png) [@EShen\_Shiou](https://forum.xojo.com/u/EShen_Shiou)\
**Post date:** [January 6, 2014, 3:23am UTC](https://forum.xojo.com/t/help-for-gtk-api-calling/13441/1 "2014-01-06T03:23:45Z")

</div>

I want write a program, and need to check is input method is running (Xojo’s KeyDown event always raised, so that I can’t confirm if user press a key is input Chinese Word or want to move position. )

API URL?[https://developer.gnome.org/gtk3/stable/GtkIMContext.html#gtk-im-context-filter-keypress](https://developer.gnome.org/gtk3/stable/GtkIMContext.html#gtk-im-context-filter-keypress)

And I am not sure how to call it correctly…

[code]//Soft Declare Function gtk\_im\_multicontext\_new Lib “gtk” () As Ptr  
Declare Function gtk\_im\_multicontext\_new lib “libgtk-x11-2.0.so” as Ptr  
//Declare Function gtk\_im\_context\_filter\_keypress lib “libgtk-x11-2.0.so” (GtkIMContext as Ptr, GdkEventKey as Ptr) as Boolean  
//Declare Function gtk\_im\_context\_filter\_keypress lib “libgtk-x11-2.0.so” () as Boolean  
Soft Declare Function gtk\_im\_context\_filter\_keypress Lib “gtk” () as Boolean

'Dim im\_context,EventKey As MemoryBlock  
'im\_context=gtk\_im\_multicontext\_new()

'Label1.Text=CStr(gtk\_im\_context\_filter\_keypress(im\_context,EventKey))  
If gtk\_im\_context\_filter\_keypress()=True Then  
Label1.Text=“True”  
Else  
Label1.Text=“False”  
End If[/code]

Please help~ Thanks~

---

<div class="post-metadata">

**Author:** ![jim\_mckay](https://forum.xojo.com/user_avatar/forum.xojo.com/jim_mckay/32/905_2.png) [@jim\_mckay](https://forum.xojo.com/u/jim_mckay)\
**Post date:** [January 6, 2014, 3:43pm UTC](https://forum.xojo.com/t/help-for-gtk-api-calling/13441/2 "2014-01-06T15:43:27Z")

</div>

I think you need to override the event handler to get EventKey. Not sure how to do that in Linux… or if it’s even possible via declares. Might require a plugin. Maybe MBS can help?  
[https://developer.gnome.org/gtkmm-tutorial/3.4/sec-keyboardevents-overview.html.en](https://developer.gnome.org/gtkmm-tutorial/3.4/sec-keyboardevents-overview.html.en)

---

<div class="post-metadata">

**Author:** ![EShen\_Shiou](https://forum.xojo.com/user_avatar/forum.xojo.com/eshen_shiou/32/7645_2.png) [@EShen\_Shiou](https://forum.xojo.com/u/EShen_Shiou)\
**Post date:** [January 7, 2014, 4:04am UTC](https://forum.xojo.com/t/help-for-gtk-api-calling/13441/3 "2014-01-07T04:04:46Z")

</div>

I know there’s GdkEventKey struct, but I’m don’t how do it with xojo… ~"~  
[https://developer.gnome.org/gdk/stable/gdk-Event-Structures.html#GdkEventKey](https://developer.gnome.org/gdk/stable/gdk-Event-Structures.html#GdkEventKey)

And I tried MBS Plugin, same as KeyDown/KeyUp problem, I can’t difference it’s in input method or not…

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [January 7, 2014, 4:28am UTC](https://forum.xojo.com/t/help-for-gtk-api-calling/13441/4 "2014-01-07T04:28:12Z")

</div>

Are you trying to capture keys in a text field or text area & decide ?

---

<div class="post-metadata">

**Author:** ![EShen\_Shiou](https://forum.xojo.com/user_avatar/forum.xojo.com/eshen_shiou/32/7645_2.png) [@EShen\_Shiou](https://forum.xojo.com/u/EShen_Shiou)\
**Post date:** [January 7, 2014, 5:04am UTC](https://forum.xojo.com/t/help-for-gtk-api-calling/13441/5 "2014-01-07T05:04:29Z")

</div>

I capture keys in a TextField(1) , and I want to move to next TextField(2) when user press ? .  
But when user press down, he may choice a word in input method, also may really want to go next TextFiled…

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [January 7, 2014, 5:09am UTC](https://forum.xojo.com/t/help-for-gtk-api-calling/13441/6 "2014-01-07T05:09:05Z")

</div>

Well then I’ll ask “does this work correctly in the code editor in the IDE on Linux ?”  
If it does then you might want to NOT use a TextArea and consider using the TextInputCanvas.  
If it does not then I’d guess we have an issue we need to fix in the text input canvas.

---

<div class="post-metadata">

**Author:** ![EShen\_Shiou](https://forum.xojo.com/user_avatar/forum.xojo.com/eshen_shiou/32/7645_2.png) [@EShen\_Shiou](https://forum.xojo.com/u/EShen_Shiou)\
**Post date:** [January 7, 2014, 5:46am UTC](https://forum.xojo.com/t/help-for-gtk-api-calling/13441/7 "2014-01-07T05:46:59Z")

</div>

I think there’s no issue with everything, the keyboard is pressed surely, so that KeyDown/KeyUp raised is correct.  
So it’s not only happen in Linux, also happen in Mac/Windows.

In my think, I want to use API to check if user in input method, so I found the “gtk-im-context-filter-keypress”.

Now I will try TextInputCanvas, if I make sense how it compiler…

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [January 7, 2014, 6:04am UTC](https://forum.xojo.com/t/help-for-gtk-api-calling/13441/8 "2014-01-07T06:04:36Z")

</div>

I can say that in OS X the only way to make this work is to use the TextInputCanvas as you cannot handle input methods without it  
I’m not certain that is true on Linux & Windows

---

<div class="post-metadata">

**Author:** ![EShen\_Shiou](https://forum.xojo.com/user_avatar/forum.xojo.com/eshen_shiou/32/7645_2.png) [@EShen\_Shiou](https://forum.xojo.com/u/EShen_Shiou)\
**Post date:** [January 7, 2014, 6:25am UTC](https://forum.xojo.com/t/help-for-gtk-api-calling/13441/9 "2014-01-07T06:25:42Z")

</div>

I still had no idea how TextInputCanvas compiler…

In Xcode, It’s shows 2 warnning, but said success. (and I don’t find where it is.)  
[http://i.imgur.com/HcEzxHy.png](http://i.imgur.com/HcEzxHy.png)

In Ubuntu, It’s shows no gtk±2.0 package, I will try build in other version of linux.  
[http://i.imgur.com/OOAtBCv.jpg](http://i.imgur.com/OOAtBCv.jpg)

---

<div class="post-metadata">

**Author:** ![Mike\_Cotrone](https://forum.xojo.com/user_avatar/forum.xojo.com/mike_cotrone/32/19940_2.png) [@Mike\_Cotrone](https://forum.xojo.com/u/Mike_Cotrone)\
**Post date:** [January 7, 2014, 6:39am UTC](https://forum.xojo.com/t/help-for-gtk-api-calling/13441/10 "2014-01-07T06:39:26Z")

</div>

[TextInputCanvas Compiled Plugin](https://xojo.io/0b6176d272e7)

HTH.

---

<div class="post-metadata">

**Author:** ![EShen\_Shiou](https://forum.xojo.com/user_avatar/forum.xojo.com/eshen_shiou/32/7645_2.png) [@EShen\_Shiou](https://forum.xojo.com/u/EShen_Shiou)\
**Post date:** [January 7, 2014, 7:10am UTC](https://forum.xojo.com/t/help-for-gtk-api-calling/13441/11 "2014-01-07T07:10:33Z")

</div>

WOW!!  
Thanks a lot. I’ll try it~

---

<div class="post-metadata">

**Author:** ![EShen\_Shiou](https://forum.xojo.com/user_avatar/forum.xojo.com/eshen_shiou/32/7645_2.png) [@EShen\_Shiou](https://forum.xojo.com/u/EShen_Shiou)\
**Post date:** [January 7, 2014, 2:20pm UTC](https://forum.xojo.com/t/help-for-gtk-api-calling/13441/12 "2014-01-07T14:20:33Z")

</div>

Not work in Linux, seems I had to try compiler it under Ubuntu.

---

<div class="post-metadata">

**Author:** ![Mike\_Cotrone](https://forum.xojo.com/user_avatar/forum.xojo.com/mike_cotrone/32/19940_2.png) [@Mike\_Cotrone](https://forum.xojo.com/u/Mike_Cotrone)\
**Post date:** [January 7, 2014, 3:43pm UTC](https://forum.xojo.com/t/help-for-gtk-api-calling/13441/13 "2014-01-07T15:43:21Z")

</div>

Yes sorry It was late and I forgot to add that I compiled it on Mac OS with XCode 5.

---

<div class="post-metadata">

**Author:** ![EShen\_Shiou](https://forum.xojo.com/user_avatar/forum.xojo.com/eshen_shiou/32/7645_2.png) [@EShen\_Shiou](https://forum.xojo.com/u/EShen_Shiou)\
**Post date:** [January 7, 2014, 3:55pm UTC](https://forum.xojo.com/t/help-for-gtk-api-calling/13441/14 "2014-01-07T15:55:36Z")

</div>

You don’t need to say that. Very thanks for your help.

I don’t know even how to compiler in XCode.

---

<div class="post-metadata">

**Author:** ![EShen\_Shiou](https://forum.xojo.com/user_avatar/forum.xojo.com/eshen_shiou/32/7645_2.png) [@EShen\_Shiou](https://forum.xojo.com/u/EShen_Shiou)\
**Post date:** [January 7, 2014, 7:05pm UTC](https://forum.xojo.com/t/help-for-gtk-api-calling/13441/15 "2014-01-07T19:05:25Z")

</div>

Compiled successful.

Enter ‘make’ command at same Folder in Terminal.  
If it show’s no gtk2 lib, run ‘sudo apt-get install libgtk2.0-dev’.  
Then you will get a .so file as a plug-in.

---

<div class="post-metadata">

**Author:** ![Mike\_Cotrone](https://forum.xojo.com/user_avatar/forum.xojo.com/mike_cotrone/32/19940_2.png) [@Mike\_Cotrone](https://forum.xojo.com/u/Mike_Cotrone)\
**Post date:** [January 7, 2014, 7:20pm UTC](https://forum.xojo.com/t/help-for-gtk-api-calling/13441/16 "2014-01-07T19:20:43Z")

</div>

Great job EShen!

---

<div class="post-metadata">

**Author:** ![EShen\_Shiou](https://forum.xojo.com/user_avatar/forum.xojo.com/eshen_shiou/32/7645_2.png) [@EShen\_Shiou](https://forum.xojo.com/u/EShen_Shiou)\
**Post date:** [January 7, 2014, 7:22pm UTC](https://forum.xojo.com/t/help-for-gtk-api-calling/13441/17 "2014-01-07T19:22:56Z")

</div>

Thanks. 🙂

Now I’m finding documents of this control…

Trying how to input with it… ~"~

---

<div class="post-metadata">

**Author:** ![Mike\_Cotrone](https://forum.xojo.com/user_avatar/forum.xojo.com/mike_cotrone/32/19940_2.png) [@Mike\_Cotrone](https://forum.xojo.com/u/Mike_Cotrone)\
**Post date:** [January 7, 2014, 7:29pm UTC](https://forum.xojo.com/t/help-for-gtk-api-calling/13441/18 "2014-01-07T19:29:25Z")

</div>

This is a good thread from Norman and Joe of Xojo talking about what documentation there is for it.

[TextInputCanvas Info Thread](https://forum.xojo.com/3485-syntaxhighlighteditfield/0)

HTH

---

<div class="post-metadata">

**Author:** ![EShen\_Shiou](https://forum.xojo.com/user_avatar/forum.xojo.com/eshen_shiou/32/7645_2.png) [@EShen\_Shiou](https://forum.xojo.com/u/EShen_Shiou)\
**Post date:** [January 7, 2014, 7:56pm UTC](https://forum.xojo.com/t/help-for-gtk-api-calling/13441/19 "2014-01-07T19:56:03Z")

</div>

Very useful. I’m reading. Thank you~~

---

<div class="post-metadata">

**Author:** ![EShen\_Shiou](https://forum.xojo.com/user_avatar/forum.xojo.com/eshen_shiou/32/7645_2.png) [@EShen\_Shiou](https://forum.xojo.com/u/EShen_Shiou)\
**Post date:** [January 7, 2014, 8:39pm UTC](https://forum.xojo.com/t/help-for-gtk-api-calling/13441/20 "2014-01-07T20:39:46Z")

</div>

Still had no idea how to use it… \<(???)"a

Many Events look like methods and properties.

Are there any examples?

[Next page](https://forum.xojo.com/t/help-for-gtk-api-calling/13441.md?page=2)
