Fixed non-correct TextCtrl's update on wxEVT_KILL_FOCUS (partially related to #3482),
when for Parameter validation dialog "Selecting NO caused no change". OSX:TextCtrl:wxEVT_KILL_FOCUS: Second call is suppressed + Under OSX set a little bit more wider width for Fields
This commit is contained in:
parent
1850685431
commit
d1e3435956
@ -79,6 +79,11 @@ void Field::PostInitialize()
|
|||||||
BUILD();
|
BUILD();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Values of width to alignments of fields
|
||||||
|
int Field::def_width() { return wxOSX ? 8 : 7; }
|
||||||
|
int Field::def_width_wider() { return 14; }
|
||||||
|
int Field::def_width_thinner() { return 4; }
|
||||||
|
|
||||||
void Field::on_kill_focus()
|
void Field::on_kill_focus()
|
||||||
{
|
{
|
||||||
// call the registered function if it is available
|
// call the registered function if it is available
|
||||||
@ -240,6 +245,8 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
|
|||||||
set_value(wxString::Format("%s%%", stVal), false/*true*/);
|
set_value(wxString::Format("%s%%", stVal), false/*true*/);
|
||||||
str += "%%";
|
str += "%%";
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
set_value(stVal, false); // it's no needed but can be helpful, when inputted value contained "," instead of "."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -367,14 +374,23 @@ void TextCtrl::BUILD() {
|
|||||||
temp->Bind(wxEVT_KILL_FOCUS, ([this, temp](wxEvent& e)
|
temp->Bind(wxEVT_KILL_FOCUS, ([this, temp](wxEvent& e)
|
||||||
{
|
{
|
||||||
e.Skip();
|
e.Skip();
|
||||||
|
#ifdef __WXOSX__
|
||||||
|
// OSX issue: For some unknown reason wxEVT_KILL_FOCUS is emitted twice in a row
|
||||||
|
// Thus, suppress its second call
|
||||||
|
if (bKilledFocus) {
|
||||||
|
bKilledFocus = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bKilledFocus = true;
|
||||||
|
#endif // __WXOSX__
|
||||||
|
|
||||||
#if !defined(__WXGTK__)
|
#if !defined(__WXGTK__)
|
||||||
temp->GetToolTip()->Enable(true);
|
temp->GetToolTip()->Enable(true);
|
||||||
#endif // __WXGTK__
|
#endif // __WXGTK__
|
||||||
if (bEnterPressed) {
|
if (bEnterPressed)
|
||||||
bEnterPressed = false;
|
bEnterPressed = false;
|
||||||
return;
|
else
|
||||||
}
|
propagate_value();
|
||||||
propagate_value();
|
|
||||||
}), temp->GetId());
|
}), temp->GetId());
|
||||||
|
|
||||||
// select all text using Ctrl+A
|
// select all text using Ctrl+A
|
||||||
@ -423,10 +439,12 @@ bool TextCtrl::value_was_changed()
|
|||||||
|
|
||||||
void TextCtrl::propagate_value()
|
void TextCtrl::propagate_value()
|
||||||
{
|
{
|
||||||
if (is_defined_input_value<wxTextCtrl>(window, m_opt.type) && value_was_changed())
|
if (!is_defined_input_value<wxTextCtrl>(window, m_opt.type) )
|
||||||
on_change_field();
|
// on_kill_focus() cause a call of OptionsGroup::reload_config(),
|
||||||
else
|
// Thus, do it only when it's really needed (when undefined value was input)
|
||||||
on_kill_focus();
|
on_kill_focus();
|
||||||
|
else if (value_was_changed())
|
||||||
|
on_change_field();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextCtrl::set_value(const boost::any& value, bool change_event/* = false*/) {
|
void TextCtrl::set_value(const boost::any& value, bool change_event/* = false*/) {
|
||||||
|
@ -225,10 +225,10 @@ public:
|
|||||||
bool get_enter_pressed() const { return bEnterPressed; }
|
bool get_enter_pressed() const { return bEnterPressed; }
|
||||||
void set_enter_pressed(bool pressed) { bEnterPressed = pressed; }
|
void set_enter_pressed(bool pressed) { bEnterPressed = pressed; }
|
||||||
|
|
||||||
// Values of width to "systematic" alignments of fields
|
// Values of width to alignments of fields
|
||||||
static int def_width() { return 7; }
|
static int def_width() ;
|
||||||
static int def_width_wider() { return 14; }
|
static int def_width_wider() ;
|
||||||
static int def_width_thinner() { return 4; }
|
static int def_width_thinner() ;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
RevertButton* m_Undo_btn = nullptr;
|
RevertButton* m_Undo_btn = nullptr;
|
||||||
@ -274,6 +274,11 @@ class TextCtrl : public Field {
|
|||||||
bool bChangedValueEvent = true;
|
bool bChangedValueEvent = true;
|
||||||
void change_field_value(wxEvent& event);
|
void change_field_value(wxEvent& event);
|
||||||
#endif //__WXGTK__
|
#endif //__WXGTK__
|
||||||
|
|
||||||
|
#ifdef __WXOSX__
|
||||||
|
bool bKilledFocus = false;
|
||||||
|
#endif // __WXOSX__
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TextCtrl(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {}
|
TextCtrl(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {}
|
||||||
TextCtrl(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {}
|
TextCtrl(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {}
|
||||||
|
Loading…
Reference in New Issue
Block a user