Fix meta key + 1..9 dialog switch in transparent.cpp

This commit is contained in:
Markus Gans 2016-09-05 19:14:51 +02:00
parent 6749164aca
commit fa037ee3ec
2 changed files with 19 additions and 15 deletions

View File

@ -32,16 +32,7 @@ class Transparent : public FDialog
Transparent (const Transparent&); // Disabled copy constructor Transparent (const Transparent&); // Disabled copy constructor
Transparent& operator = (const Transparent&); // and operator '=' Transparent& operator = (const Transparent&); // and operator '='
void draw(); void draw();
void onAccel (FAccelEvent* ev) void onKeyPress (FKeyEvent* ev);
{
if ( getParentWidget() )
{
if ( getParentWidget()->close() )
ev->accept();
else
ev->ignore();
}
}
public: public:
explicit Transparent (FWidget* = 0, trans_type = transparent); // constructor explicit Transparent (FWidget* = 0, trans_type = transparent); // constructor
@ -55,7 +46,6 @@ Transparent::Transparent (FWidget* parent, Transparent::trans_type tt)
, type(tt) , type(tt)
{ {
setStatusbarMessage("Press Q to quit"); setStatusbarMessage("Press Q to quit");
addAccelerator('q');
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -105,6 +95,18 @@ void Transparent::draw()
updateVTerm(true); updateVTerm(true);
} }
//----------------------------------------------------------------------
void Transparent::onKeyPress (FKeyEvent* ev)
{
if ( ev && ev->key() == 'q' && getParentWidget() )
{
if ( getParentWidget()->close() )
ev->accept();
else
ev->ignore();
}
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class MainWindow // class MainWindow
@ -126,11 +128,14 @@ class MainWindow : public FDialog
void onClose (FCloseEvent*); void onClose (FCloseEvent*);
void onShow (FShowEvent*); void onShow (FShowEvent*);
void onTimer (FTimerEvent*); void onTimer (FTimerEvent*);
void onAccel (FAccelEvent* ev) void onKeyPress (FKeyEvent* ev)
{
if ( ev && ev->key() == 'q' )
{ {
close(); close();
ev->accept(); ev->accept();
} }
}
public: public:
explicit MainWindow (FWidget* = 0); // constructor explicit MainWindow (FWidget* = 0); // constructor

View File

@ -844,7 +844,6 @@ int main (int argc, char* argv[])
d.setText (title); d.setText (title);
d.setGeometry (int((app.getWidth()-56)/2), 2, 56, app.getHeight()-4); d.setGeometry (int((app.getWidth()-56)/2), 2, 56, app.getHeight()-4);
d.setShadow(); d.setShadow();
d.setResizeable();
app.setMainWidget(&d); app.setMainWidget(&d);
d.show(); d.show();