ivan.cuevas Posted December 11, 2014 Posted December 11, 2014 Hi all, I want to create a screen keyboard for desktop touch devices. Because I want it to be multiplatform (Win, Linux and OSX) and skinable my first intention it's to make it completely in UnigineScript. The idea is, every time a key sprite is pressed, inject the corrensponding key event. the problem is engine.app.setKeyState doesn't accept other keys but APP_KEY_*. There is any other way to inject key events to the application? Thanks in advance.
unclebob Posted December 11, 2014 Posted December 11, 2014 Hi Iván, It actually accepts ascii keycodes. For example, if you want to set key 'a', you need to do the following: engine.app.setKeyState('a');
ivan.cuevas Posted December 12, 2014 Author Posted December 12, 2014 Hi Andrey, thanks for the answer. I tried this: /* */ void _click() { log.message("click!"); engine.app.setKeyState('a', 1); } /* */ void foo(int key) { log.message("key: %d", key); } /* */ int init() { Gui gui= engine.getGui(); WidgetButton btn= new WidgetButton(gui, "Press"); btn.setCallback(GUI_CLICKED, "_click"); btn.setData("a"); gui.addChild(btn, GUI_ALIGN_BOTTOM); //register callback to receive key events. engine.gui.setKeyPressCallback("foo"); return 1; } /* */ int shutdown() { return 1; } /* */ int update() { if(engine.app.clearKeyState('a')) log.message("a pressed"); return 1; } Looks like gui system is not receiving key event.
unclebob Posted December 12, 2014 Posted December 12, 2014 Because that callbacks are triggered by os keypress events. So I suggest you to manually call that keypress function inside widget callback.
Recommended Posts