Author Topic: wxKeyEvent  (Read 6677 times)

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
wxKeyEvent
« on: December 29, 2006, 05:48:30 am »
Hi guys.

This is probably a wxWidgets question more than a C::B question, but here goes:

I'm writing some code to run a process in a dockable panel in Code::Blocks. To do this i need to intercept keystroke events to the textctrl in the panel. Presumably, it is enough to trap EVT_CHAR and pass a wxKeyEvent to a relevant handler. Does any know if keystrokes have to be handled within the textctrl (i.e. do I have to subclass my own textctrl and declare an event table for it) or can it be handled by my subclassed wxPanel which is the parent of the textctrl?

(I'm assuming there is nothing in C::B that prevents me from processing EVT_CHAR events)

Offline Game_Ender

  • Lives here!
  • ****
  • Posts: 551
Re: wxKeyEvent
« Reply #1 on: December 29, 2006, 09:06:55 am »
Do you mean you are using a wxTextCtrl and want to not process wxKeyEvents? or you want to process wxKeyEvent's in another control.  You can process wxKeyEvent's for any control not just wxTextCtrls.  I trust you have looked at the key event demo that comes with wxWidgets.   It will show you what all those different key events report exactly.

Are you trying to make a shell like interpreter?

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: wxKeyEvent
« Reply #2 on: December 29, 2006, 10:54:36 pm »
Do you mean you are using a wxTextCtrl and want to not process wxKeyEvents?

no, i want to process it's key events and pass the keys to stdin of an external process, but was silly enough to think i could do this from its parent. shortly after i posted realized i can't do this and had to subclass the wxtextctrl and define my own event handler for it, which is a PITA.

Quote
Are you trying to make a shell like interpreter?

sort of... i want to redirect I/O from a console program to a dockable window. this will never be perfect because special keys like back space and arrows have behavior that's hard to mimic unless you can get some sort of local echo on stdout. (e.g. backspace will delete characters on a command line, but only as far as the command prompt, so you need to get some feedback from the console about whether to delete the next char or not)

any better ideas than a wxTextCtrl? i thought someone had a wxProcess replacement on the way that might offer some better way of doing this, but got sick of waiting...

Offline Game_Ender

  • Lives here!
  • ****
  • Posts: 551
Re: wxKeyEvent
« Reply #3 on: December 30, 2006, 07:45:01 am »
You got me, I have been looking for the a simple terminal, like gedit but not thousands of lines of code, so I could see how its done.  Basically I want to make a wxWidget based terminal emulator, but I need a better reference.

EDIT: Terminator is one written in Java with a small amount of C++.  If anyone wants a decent reference application Java is probably cleaner the C + X11/GTK which is what most other open source terminal emulators are written in.
« Last Edit: December 30, 2006, 07:57:59 am by Game_Ender »