problem with Edit Boxes

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
yin nadie

problem with Edit Boxes

Post by yin nadie »

I've got a window created as this:

gui::IGUIWindow* window = env->addWindow(core::rect<s32>(220, 180, 420, 300), false, L"Connect to...", 0, 101);
env->addStaticText(L"IP address:", core::rect<s32>(10,30,90,50),false, false, window);
env->addEditBox(L"000.000.000.000", core::rect<s32>(80,30,190,50), true, window, 102);
env->addStaticText(L"port:", core::rect<s32>(10,60,90,80),false, false, window);
env->addEditBox(L"80", core::rect<s32>(80,60,190,80), true, window, 103);
env->addButton(core::rect<s32>(10,90,190,110), window, 104, L"Connect!");

(the env variable has been declared as: env = device->getGUIEnvironment(); device has been initialized, etc. )

It compiles correctly, but when executed, I can't type anythig inside the edit boxes. I can delete the contents just fine, using either BACKSPACE or SUPR, but can't write any new character.

Note: i'm compiling under linux mandrake 9.2

Please, help.
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

There are still some problems with linux and key input, sorry for that. Hope I'll fix that soon.
mm765
Posts: 172
Joined: Fri May 28, 2004 10:12 am

fix for linux key input

Post by mm765 »

not sure if this is the best way to do it, but it works for me:

CIrrDeviceLinux.h DIFF:
228a230,232
> bool shiftKeyActive;
> bool controlKeyActive;
> bool altKeyActive;


CIrrDeviceLinux.cpp DIFF:
73a74,76
> shiftKeyActive = false;
> controlKeyActive = false;
> altKeyActive = false;
440a445,474
> // if one of the modifiers (shift/control) is pressed, just update the status flag
> if(mp.X11Key == XK_Shift_L || mp.X11Key == XK_Shift_R)
> {
> shiftKeyActive = !shiftKeyActive;
> break;
> }
> if(mp.X11Key == XK_Control_L || mp.X11Key == XK_Control_R)
> {
> controlKeyActive = !controlKeyActive;
> break;
> }
> if(mp.X11Key == XK_Alt_L || mp.X11Key == XK_Alt_R)
> {
> altKeyActive = !altKeyActive;
> break;
> }
>
> // change keyvalue depending on shift/control flags
> if(mp.X11Key >= XK_a && mp.X11Key <= XK_z)
> {
> if(shiftKeyActive)
> {
> mp.X11Key -= 32;
> }
> if(controlKeyActive)
> {
> mp.X11Key -= 96;
> }
> }
>
448,450c482,484
< irrevent.KeyInput.Char = mp.X11Key; // TODO: find right character
< irrevent.KeyInput.Control = false; // TODO
< irrevent.KeyInput.Char = false; // TODO
---
> irrevent.KeyInput.Char = mp.X11Key;
> irrevent.KeyInput.Control = controlKeyActive;
> irrevent.KeyInput.Shift = shiftKeyActive;

edit: better version that also captures the alt-key so alt-f4 now works within linux, too and the error message "no win32 key found" is gone.
Post Reply