How do you Turn off a wxTextCtrl Insertion Point? Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
User avatar
ColleenKobe
Experienced Solver
Experienced Solver
Posts: 88
Joined: Mon Aug 31, 2015 3:47 pm

How do you Turn off a wxTextCtrl Insertion Point?

Post by ColleenKobe » Tue Feb 27, 2018 8:03 pm

I have a wxTextCtrl field called m_Eq_m. The only event I use to modify or save its contents is wxEVT_KILL_FOCUS. At the end of my OnEq_m_Kill_Focus procedure, I use SetValue to update the field. (i.e.

Code: Select all

m_Eq_m->SetValue (temp_st);
)

Here's what happens:

1. I click inside m_Eq_m to make it the focus. Its border gets darker.

2. I type in "3.14" (without the quotes), which is a legal number.

3. I press the tab key to advance to the next field, which is a wxButton.

4. The border around m_Eq_m gets lighter, and the border around the wxButton gets darker, so I know the focus has correctly moved.

5. BUT the insertion point is still visible on the screen in the m_Eq_m field.

Having the insertion point visible, when the wxButton is clearly the focus, is endlessly confusing.
Worse, when I press tab to move the focus around, when the focus exits m_Eq_m without editing, the field stays highlighted. And the insertion point is still there.

How to I make the insertion point invisible? Or visible?

In http://docs.wxwidgets.org/3.0/classwx_text_ctrl.html, I see GetInsertionPoint, SetInsertionPoint, and SetInsertionPointEnd. But I don't see anything about InsertionPointShow or InsertionPointHide. :-(


Versions:

CodeLite 11.0.8
wxCrafter

Thanks!

Colleen

User avatar
doublemax
Moderator
Moderator
Posts: 14770
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: How do you Turn off a wxTextCtrl Insertion Point?

Post by doublemax » Tue Feb 27, 2018 8:42 pm

That shouldn't happen and it doesn't happen in any sample i tried.

Wild guess: Do you call event.Skip() in the wxEVT_KILL_FOCUS handler? If not, try that.
Use the source, Luke!

User avatar
ColleenKobe
Experienced Solver
Experienced Solver
Posts: 88
Joined: Mon Aug 31, 2015 3:47 pm

Re: How do you Turn off a wxTextCtrl Insertion Point?

Post by ColleenKobe » Tue Feb 27, 2018 9:52 pm

Hi, doublemax,

No, I did not call event.Skip() in my wxEVT_KILL_FOCUS code.

And yes, when I added it at the top of the procedure, the insertion point worked perfectly and the highlighting problem went away!

Woo hoo! You're a genius. Thank you!!!

Tomorrow I will look up event.Skip to find out what it does.

Colleen

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4043
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: How do you Turn off a wxTextCtrl Insertion Point?

Post by ONEEYEMAN » Wed Feb 28, 2018 4:11 pm

Hi,
Basically event.Skip() call let the the event loop continue processing the message up until the native control.
If you don't call it, the event will be eaten by your program and the native control will never have a chance to finish processing the message.

Calling this method is a requirement for all non-wxCommandEvent, except maybe EVT_PAINT. Unless you absolutely know what you are doing.

Thank you.

Post Reply