First you need to see to this bug "PLT-19966", it is a bug which only appear in linux GUI(Tachyon and Tflex). It exist in our SetupTree, Usage Monitor, RET Seting... You can easily get it when you select some text in a wxTextCtrl and then swich cursor to other empty textctrl. Then the text you selected will just 'disappear'
after select part of the text and switch cursor to other textCtrl It cost me lots of time to debug and find out the root cause of this bug. Maybe you wouldn’t believe it cause by a general function which we use frequently: Disalbe() & Enable() Here I get a demo app to reproduce this bug: I get a frame which have controls as you see , 2 buttons and 2 textCtrl. After click Btn1 , it will start a timer and Disable the whole frame by invoke Diable;
And after 2s, the timer is timeout and will invoke Enable() to enable the frame again.
then you can select the text "st" int "test", switch to the textCtrl beside it and then 'st' disappear. The disgustind bug came out again.
You can test it in frame, dialog, and even panel which contain wxTextCtrl. If you really want to enable all controls in a frame,dialog, and panel, you can use below code instead. It will loop all its children and invoke child's enable function one by one(it won't cause problem).
After dig into the wxWidgets source code in GTK version, I find maybe cause by the gtk function " gtk_widget_set_sensitive" which maybe can't resume all event correctly .
I don't exactly whether it is a bug of GTK or wxWidgets. And want to remind you: Be careful next time when you want to use Disable and Enable(false) function to disable a whole frame,dialog or other windows contains controls like panel. Thanks. |
The question has been closed for the following reason "Other" by Echo Jan 16 at 17:00
This bug is fixed in the latest wxWidget. But nobody know why, they just simply removed wxTextCtrl::OnEnabled(),that is OnParentEnable() function in v2.8.9. Replacing Enable() with EnableAllChild() is buggy, we should upgrade the wxwidget now. answered Jan 15 at 17:46 miliao |
We can disable our controls in a frame or dialog one by one,it won't cause any problem. But we can't use frame->Disable() to disable all controls in that frame. Though frame->Disable() will also loop all controls and disable them one by one, but it also invoke
as you can see in the function above:
It seem there's something wrong with this GTK function, because I don't familiar with GTK programming , so I also don't why. Calling EnableAllChild is a function loop all controls and disable them one by one , and it don't invoke gtk_widget_set_sensitive. answered Sep 24 '13 at 14:13 junbin Good work!I can image it is not easy to find out all these. This bug is weird. Maybe we can do some more test on the Enable/Disable to locate the correct behavior, or at least what is the real cause on earth. After all, Eanble() and EnableAllChild() are different and thus have different effect. Simply replacing Enable() with EnableAllChild() is not a perfect solution I think. And this still can not explain everything,eg, why we have to set other textctrl empty to reproduce this bug, and the lose-focus issue. I guess there is something more in it. |
Be careful, this bug will also cause by using 'SetBackgroundColour', like:
you can easily write a demo to test it in linux. answered Oct 08 '13 at 17:11 junbin |
For this issue, the simplest/safe solution is to write our own TextCtrl.
Already tested, above solution works. answered Jan 16 at 19:36 Zero |
Follow this question
By Email:You are not subscribed to this question.
(you can adjust your notification settings on yourprofile)
By RSS:Markdown Basics
- *italic* or __italic__
- **bold** or __bold__
- link:[text](http://url.com/ "title")
- image?![alt text](/path/img.jpg "title")
- numbered list: 1. Foo 2. Bar
- to add a line break simply add two spaces to where you would like the new line to be.
- basic HTML tags are also supported
Tags:
Asked: Sep 24 '13 at 13:25
Seen: 48 times
Last updated: Jan 16 at 19:36
Great work! Thanks!
So the finial solution is to call EnableAllChild instead of Enable? I'm still confused why this can fix the bug.