Bug fix disable cursor on focus FSwitch

This commit is contained in:
Markus Gans 2015-07-06 22:43:56 +02:00
parent 7844923d79
commit 71050832ac
3 changed files with 15 additions and 11 deletions

View File

@ -60,7 +60,8 @@ void FSwitch::drawCheckButton()
print (" On "); print (" On ");
setColor (wc.button_inactive_fg, wc.button_inactive_bg); setColor (wc.button_inactive_fg, wc.button_inactive_bg);
print (" Off "); print (" Off ");
gotoxy (xpos+xmin+2+switch_offset_pos, ypos+ymin-1); setCursorPos ( xpos + xmin + 1 + switch_offset_pos,
ypos + ymin - 1 );
} }
else else
{ {
@ -71,7 +72,8 @@ void FSwitch::drawCheckButton()
else else
setColor (wc.button_hotkey_fg, wc.button_active_bg); setColor (wc.button_hotkey_fg, wc.button_active_bg);
print (" Off "); print (" Off ");
gotoxy (xpos+xmin+6+switch_offset_pos, ypos+ymin-1); setCursorPos ( xpos + xmin + 5 + switch_offset_pos,
ypos + ymin - 1 );
} }
} }

View File

@ -64,7 +64,9 @@ void FToggleButton::init()
this->text = ""; this->text = "";
setGeometry (1, 1, 4, 1, false); // initialize geometry values setGeometry (1, 1, 4, 1, false); // initialize geometry values
setVisibleCursor();
if ( isRadioButton() || isCheckboxButton() )
setVisibleCursor();
if ( hasFocus() ) if ( hasFocus() )
this->flags = FOCUS; this->flags = FOCUS;
@ -151,9 +153,9 @@ void FToggleButton::draw()
} }
} }
// set the cursor to the button
if ( isRadioButton() || isCheckboxButton() ) if ( isRadioButton() || isCheckboxButton() )
{ {
// set the cursor to the button
setCursorPos (xpos+xmin, ypos+ymin-1); setCursorPos (xpos+xmin, ypos+ymin-1);
if ( isCursorInside() && hasFocus() ) if ( isCursorInside() && hasFocus() )
@ -407,7 +409,7 @@ bool FToggleButton::setFocus(bool on)
foregroundColor = wc.toggle_button_active_focus_fg; foregroundColor = wc.toggle_button_active_focus_fg;
backgroundColor = wc.toggle_button_active_focus_bg; backgroundColor = wc.toggle_button_active_focus_bg;
if ( isCursorInside() ) if ( isCursorInside() && (isRadioButton() || isCheckboxButton()) )
showCursor(); showCursor();
if ( statusBar() ) if ( statusBar() )
@ -536,7 +538,7 @@ void FToggleButton::onHide (FHideEvent*)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FToggleButton::onFocusIn (FFocusEvent*) void FToggleButton::onFocusIn (FFocusEvent*)
{ {
if ( isCursorInside() ) if ( isCursorInside() && (isRadioButton() || isCheckboxButton()) )
showCursor(); showCursor();
if ( statusBar() ) if ( statusBar() )

View File

@ -62,14 +62,14 @@ watch::watch (FWidget* parent) : FDialog(parent)
seconds_sw = new FSwitch(L"Seconds", this); seconds_sw = new FSwitch(L"Seconds", this);
clock_sw->setGeometry(4, 4, 9, 1); clock_sw->setGeometry(4, 4, 9, 1);
seconds_sw->setGeometry(2, 6, 11, 1); seconds_sw->setGeometry(2, 6, 11, 1);
seconds_sw->setChecked(); clock_sw->setFocus();
sec = true; sec = seconds_sw->setChecked();
// Create button // Create button
FButton* quit = new FButton(L"&Quit", this); FButton* quit = new FButton(L"&Quit", this);
quit->setGeometry(6, 9, 9, 1); quit->setGeometry(6, 9, 9, 1);
quit->setShadow(); quit->setShadow();
quit->setFocus();
// Connect switch signal "toggled" with a callback member function // Connect switch signal "toggled" with a callback member function
clock_sw->addCallback clock_sw->addCallback