[Gtk-sharp-list] sending characters onto the active window
Christian Hoff
christian_hoff at gmx.net
Fri Apr 3 06:47:41 EDT 2009
Maybe that snippet helps:
foreach (Gtk.Window wnd in Gtk.Window.ListToplevels ()) {
if (wnd.HasToplevelFocus) {
Gtk.Widget FocusedWidget = wnd.Focus;
if (FocusedWidget != null && FocusedWidget is
Gtk.Entry) {
int pos = (FocusedWidget as Gtk.Editable).Position;
(FocusedWidget as Gtk.Entry).InsertText (code,
ref pos);
System.Console.WriteLine ("Inserted text in entry");
return;
}
}
}
I wrote that piece of code to insert characters scanned by a barcode
scanner into the active entry/text widget. It should not be difficult to
revamp it to work with TextView/TextBuffer, too. Inserting unicode
should not be a problem as both System.String and the GLib string type
store their data in unicode format.
l333t wrote:
>
> Adam Tauno Williams wrote:
>
>> On Thu, 2009-04-02 at 09:24 -0700, l333t wrote:
>>
>>> I need to know if it's possible to send characters(Unicodes in
>>> particular)
>>> onto the active window using Mono in linux. Though I don't know much
>>> about
>>> it, I know that it's possible in microsoft windows. Is it possible to
>>> achieve the same thing in linux?
>>>
>>> I am using java for my development and it's not possible to send
>>> characters
>>> onto active window using java. Sending characters is possible using
>>> Xlib..
>>> but its not possible to send unicodes using Xlib..
>>>
>
> Active window means the topmost window. The window that has focus. I'm doing
> a transliteration software which translates english to other scripts. So far
> that, i need to send unicodes of the languages to which I want to convert,
> onto the active/focus window.
>
>
More information about the Gtk-sharp-list
mailing list