Class FSwitch: disable cursor on focus
This commit is contained in:
parent
91497fbb4c
commit
cef8ec0916
|
@ -34,11 +34,13 @@ FSwitch::~FSwitch() // destructor
|
|||
void FSwitch::draw()
|
||||
{
|
||||
setUpdateVTerm(false);
|
||||
drawCheckButton();
|
||||
drawLabel();
|
||||
drawCheckButton();
|
||||
setUpdateVTerm(true);
|
||||
|
||||
FToggleButton::draw();
|
||||
updateTerminal();
|
||||
flush_out();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -47,7 +49,7 @@ void FSwitch::drawCheckButton()
|
|||
if ( ! isVisible() )
|
||||
return;
|
||||
|
||||
gotoxy (xpos+xmin-1+switch_offset_pos, ypos+ymin-1);
|
||||
gotoxy (xpos+xmin-1+switch_offset_pos, ypos+ymin-1);
|
||||
|
||||
if ( checked )
|
||||
{
|
||||
|
@ -58,6 +60,7 @@ 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);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -68,6 +71,7 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,10 +102,7 @@ void FSwitch::onKeyPress (FKeyEvent* event)
|
|||
}
|
||||
|
||||
if ( event->isAccepted() )
|
||||
{
|
||||
draw();
|
||||
updateTerminal();
|
||||
}
|
||||
else
|
||||
FToggleButton::onKeyPress(event);
|
||||
}
|
||||
|
|
|
@ -151,16 +151,19 @@ void FToggleButton::draw()
|
|||
}
|
||||
}
|
||||
|
||||
// set the cursor to the button
|
||||
setCursorPos (xpos+xmin, ypos+ymin-1);
|
||||
if ( isRadioButton() || isCheckboxButton() )
|
||||
{
|
||||
// set the cursor to the button
|
||||
setCursorPos (xpos+xmin, ypos+ymin-1);
|
||||
|
||||
if ( isCursorInside() && hasFocus() )
|
||||
{
|
||||
if ( isHiddenCursor() )
|
||||
showCursor();
|
||||
if ( isCursorInside() && hasFocus() )
|
||||
{
|
||||
if ( isHiddenCursor() )
|
||||
showCursor();
|
||||
}
|
||||
else if ( ! isHiddenCursor() )
|
||||
hideCursor();
|
||||
}
|
||||
else if ( ! isHiddenCursor() )
|
||||
hideCursor();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -254,6 +257,13 @@ bool FToggleButton::isRadioButton() const
|
|||
const_cast<char*>("FRadioButton") ) == 0 );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FToggleButton::isCheckboxButton() const
|
||||
{
|
||||
return ( strcmp (getClassName(),
|
||||
const_cast<char*>("FCheckBox") ) == 0 );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FToggleButton::onKeyPress (FKeyEvent* event)
|
||||
{
|
||||
|
|
|
@ -44,6 +44,7 @@ class FToggleButton : public FWidget
|
|||
void processToggle();
|
||||
FButtonGroup* group() const;
|
||||
bool isRadioButton() const;
|
||||
bool isCheckboxButton() const;
|
||||
virtual void onKeyPress (FKeyEvent*);
|
||||
|
||||
public:
|
||||
|
|
|
@ -286,7 +286,7 @@ MyDialog::MyDialog (FWidget* parent) : FDialog(parent)
|
|||
tagged_count->setGeometry(28, 4, 5, 1);
|
||||
tagged_count->setNumber(0);
|
||||
|
||||
FLabel* sum = new FLabel(L"Sum:", this);
|
||||
FLabel* sum = new FLabel(L"Sum:\n123\n456", this);
|
||||
sum->setGeometry(20, 5, 7, 1);
|
||||
sum->setAlignment(fc::alignRight);
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ watch::watch (FWidget* parent) : FDialog(parent)
|
|||
setText ("Watch");
|
||||
setShadow();
|
||||
int pw = parentWidget()->getWidth();
|
||||
setGeometry (1+(pw-22)/2, 3, 22, 12);
|
||||
setGeometry (1+(pw-22)/2, 3, 22, 13);
|
||||
|
||||
// Create labels
|
||||
time_label = new FLabel(L"Time", this);
|
||||
|
@ -67,7 +67,7 @@ watch::watch (FWidget* parent) : FDialog(parent)
|
|||
|
||||
// Create button
|
||||
FButton* quit = new FButton(L"&Quit", this);
|
||||
quit->setGeometry(6, 8, 9, 1);
|
||||
quit->setGeometry(6, 9, 9, 1);
|
||||
quit->setShadow();
|
||||
quit->setFocus();
|
||||
|
||||
|
|
Loading…
Reference in New Issue