मैं सूक्ति-खोल GJS उपयोग करने के लिए सरल जीटीके आवेदन बनाने के लिए कोशिश कर रहा हूँ काम नहीं करता।GJS: Gtk.TextView कुंजी प्रेस घटना
इसकी खिड़की Gtk.TextView केवल होता है और मैं जब उपयोगकर्ता लिख रहा है घटनाओं पर कार्रवाई करना चाहते हैं।
#!/usr/bin/gjs
var Gtk = imports.gi.Gtk;
function MainWindow() {
this._init();
}
MainWindow.prototype = {
_init: function() {
this.window = new Gtk.Window ({
title: "Just Calculator",
window_position: Gtk.WindowPosition.CENTER,
default_height: 400,
default_width: 440,
});
//this.window.show();
this.window.connect ("hide", Gtk.main_quit);
this.window.connect ("delete-event", function() {
Gtk.main_quit();
return true;
});
this.textbox = new Gtk.TextView();
this.textbox.connect('key-press-event', this._keyPress);
var sw = new Gtk.ScrolledWindow ({shadow_type:Gtk.ShadowType.IN});
sw.add (this.textbox);
this.window.add(sw);
this.window.show_all();
},
_keyPress: function(textview, event) {
print(event, event.type, event.keyval);
textview.buffer.text = 'ok';
return true;
}
}
Gtk.init (null, null);
var window = new MainWindow();
Gtk.main();
यह आम तौर पर काम करता है, लेकिन मैं event.keyval नहीं पढ़ सकते हैं: कंसोल आउटपुट "अनिर्धारित" है:
यहाँ मेरी कोड है
[union instance proxy GIName:Gdk.Event [email protected] [email protected]] undefined undefined
कोई मुझे बता सकते हैं कि मैं क्या कर रहा हूँ गलत? धन्यवाद!
पर इसे ठीक करने का प्रबंधन किया? – gosukiwi
इसे आजमाएं: '_keyPress: फ़ंक्शन (स्वयं, टेक्स्टव्यू, ईवेंट)' – Gonzalo