Page 1 of 1

wxTextCtrl Incorrect Focus

Posted: Mon Dec 19, 2011 7:54 pm
by Tapsa
The following customized wxTextCtrl did work with wxWidgets 2.8.12 but not with 2.9.3. I need it for checking wxTextCtrl values.
Whenever I click on some customized wxTextCtrl then click somewhere else, I can't click back to once clicked customized wxTextCtrl.
The focus stays where it was before re-clicking.
The cursor position also mimics the box which should be focused.
What could cause this problem?

Code: Select all

#ifndef TextCtrl_Short_h
#define TextCtrl_Short_h

class TextCtrl_Short : public wxTextCtrl

	TextCtrl_Short(wxWindow*, string, short*);

	/* Events */

	void OnKillFocus(wxFocusEvent& Event);

	/* Member Variables */

	short * Container;
	void * ParentContainer;
	bool NoLoadList;


TextCtrl_Short::TextCtrl_Short(wxWindow * parent, string InitValue, short * Pointer)
: wxTextCtrl(parent, wxID_ANY, InitValue, wxDefaultPosition, wxSize(0, 20), 0, wxDefaultValidator)
	Container = Pointer;
	this->SetBackgroundColour(wxColour(210, 230, 255));
	Connect(this->GetId(), wxEVT_KILL_FOCUS, wxFocusEventHandler(TextCtrl_Short::OnKillFocus));

Re: wxTextCtrl Incorrect Focus

Posted: Mon Dec 19, 2011 9:03 pm
by DavidHart

(Please use code-tags; they make source-code much easier to read. I've done it for you this time.)

One possibility, since you catch wxEVT_KILL_FOCUS: make sure you call event.Skip() in the handler, otherwise strange things may happen.



Re: wxTextCtrl Incorrect Focus

Posted: Mon Dec 19, 2011 9:08 pm
by Tapsa
Do you mean in TextCtrl_Short::OnKillFocus in my case?
HUGE thanks! It works now!