From 71050832ac8f5ae10cfb8dbcdc0d6818bfbb5c37 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Mon, 6 Jul 2015 22:43:56 +0200 Subject: [PATCH] Bug fix disable cursor on focus FSwitch --- src/fswitch.cpp | 6 ++++-- src/ftogglebutton.cpp | 14 ++++++++------ test/watch.cpp | 6 +++--- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/fswitch.cpp b/src/fswitch.cpp index 8a7625a5..d3c8c690 100644 --- a/src/fswitch.cpp +++ b/src/fswitch.cpp @@ -60,7 +60,8 @@ void FSwitch::drawCheckButton() print (" On "); setColor (wc.button_inactive_fg, wc.button_inactive_bg); print (" Off "); - gotoxy (xpos+xmin+2+switch_offset_pos, ypos+ymin-1); + setCursorPos ( xpos + xmin + 1 + switch_offset_pos, + ypos + ymin - 1 ); } else { @@ -71,7 +72,8 @@ void FSwitch::drawCheckButton() else setColor (wc.button_hotkey_fg, wc.button_active_bg); print (" Off "); - gotoxy (xpos+xmin+6+switch_offset_pos, ypos+ymin-1); + setCursorPos ( xpos + xmin + 5 + switch_offset_pos, + ypos + ymin - 1 ); } } diff --git a/src/ftogglebutton.cpp b/src/ftogglebutton.cpp index cd11b77b..1a931c8b 100644 --- a/src/ftogglebutton.cpp +++ b/src/ftogglebutton.cpp @@ -64,7 +64,9 @@ void FToggleButton::init() this->text = ""; setGeometry (1, 1, 4, 1, false); // initialize geometry values - setVisibleCursor(); + + if ( isRadioButton() || isCheckboxButton() ) + setVisibleCursor(); if ( hasFocus() ) this->flags = FOCUS; @@ -151,11 +153,11 @@ void FToggleButton::draw() } } + // set the cursor to the button if ( isRadioButton() || isCheckboxButton() ) - { - // set the cursor to the button + { setCursorPos (xpos+xmin, ypos+ymin-1); - + if ( isCursorInside() && hasFocus() ) { if ( isHiddenCursor() ) @@ -407,7 +409,7 @@ bool FToggleButton::setFocus(bool on) foregroundColor = wc.toggle_button_active_focus_fg; backgroundColor = wc.toggle_button_active_focus_bg; - if ( isCursorInside() ) + if ( isCursorInside() && (isRadioButton() || isCheckboxButton()) ) showCursor(); if ( statusBar() ) @@ -536,7 +538,7 @@ void FToggleButton::onHide (FHideEvent*) //---------------------------------------------------------------------- void FToggleButton::onFocusIn (FFocusEvent*) { - if ( isCursorInside() ) + if ( isCursorInside() && (isRadioButton() || isCheckboxButton()) ) showCursor(); if ( statusBar() ) diff --git a/test/watch.cpp b/test/watch.cpp index 6d8a72ee..dff064c2 100644 --- a/test/watch.cpp +++ b/test/watch.cpp @@ -62,14 +62,14 @@ watch::watch (FWidget* parent) : FDialog(parent) seconds_sw = new FSwitch(L"Seconds", this); clock_sw->setGeometry(4, 4, 9, 1); seconds_sw->setGeometry(2, 6, 11, 1); - seconds_sw->setChecked(); - sec = true; + clock_sw->setFocus(); + sec = seconds_sw->setChecked(); // Create button FButton* quit = new FButton(L"&Quit", this); quit->setGeometry(6, 9, 9, 1); quit->setShadow(); - quit->setFocus(); + // Connect switch signal "toggled" with a callback member function clock_sw->addCallback