DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Python (http://www.daniweb.com/forums/forum114.html)
-   -   Detecting changes in RichTextCtrl (http://www.daniweb.com/forums/thread156432.html)

MaxVK Nov 10th, 2008 2:52 pm
Detecting changes in RichTextCtrl
 
Hi there.

I am using a RichTextCtrl on a window with a toolbar. The toolbar has a save button on it that is disabled by default when the application starts.

I need this button to become enabled when the user changes something in the RichTextCtrl, but I'm having trouble working out how to detect such a change. I managed to create a KEY_DOWN event for the RichTextCtrl, but while that allowed me to enable the save button, it also prevented me from typing anything!

Can anyone point me in the right direction please?

regards

Max

Paul Thompson Nov 10th, 2008 4:09 pm
Re: Detecting changes in RichTextCtrl
 
try using wx.EVT_TEXT and bind it to the Rich Text control.

MaxVK Nov 11th, 2008 6:42 am
Re: Detecting changes in RichTextCtrl
 
Ah thanks Paul - That did it!

I'm playing with the code now (at least until I have to do some more work!) and I want to pick up some key presses to activate various functions (Bold etc). Is this the right event to do this in, or is there a better way?

Regards

Max

jlm699 Nov 11th, 2008 11:53 am
Re: Detecting changes in RichTextCtrl
 
I think the better way would just be to map CTRL+<character> to the items under an Edit menu.

ie,
File, Edit, Help
      |_Bold Ctrl+B
      |_Italic Ctrl+I

MaxVK Nov 11th, 2008 2:07 pm
Re: Detecting changes in RichTextCtrl
 
Hmm, thanks. I was hoping to avoid a menu since it wouldn't necessarily fit into what the window would be doing, but it might prove the easiest way to do this.

Thanks for your help

Regards

Max

jlm699 Nov 11th, 2008 2:33 pm
Re: Detecting changes in RichTextCtrl
 
Are you trying to make a text editor? In my opinion, a text editor would most definitely benefit from a menu system.

MaxVK Nov 12th, 2008 8:21 am
Re: Detecting changes in RichTextCtrl
 
Hmm. Text Editor. Well, sort of.

I'm an author, and the program is called 'Author Tool'. It does incorporate a text editor, but the menu would be sort of superfluous - As a tool it is designed to speed up my writing, which means Keyboard shortcuts for pretty much everything that I might do while actually typing. I use a toolbar for navigation, character creation etc.

I'm trying to re-write this program in Python, basically as a learning exercise - I have a copy that I use most days, written in Gambas.

Regards

Max

jlm699 Nov 12th, 2008 9:27 am
Re: Detecting changes in RichTextCtrl
 
I guess what you could do is set up a menu with the CTRL+<Letter> shortcuts binded and then just keep it hidden.

That way the bindings are taken care of but you don't have to see it...

MaxVK Nov 12th, 2008 12:43 pm
Re: Detecting changes in RichTextCtrl
 
Yes, I was thinking along those lines because it looks a lot simpler than setting up a large number of shortcuts for the rich text control.

Thanks

Max


All times are GMT -4. The time now is 2:56 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC