ESC button in Sketch

A subforum for research and development of the user interface of FreeCAD

Moderator: agryson

User avatar
HarryGeier
Posts: 668
Joined: Mon Jul 10, 2017 12:36 pm
Location: Hof Germany

Re: ESC button in Sketch

Postby HarryGeier » Fri Sep 07, 2018 9:49 am

There is another discussion on that matter in the developers corner.. so expect things to happen...

https://forum.freecadweb.org/viewtopic.php?f=10&t=30759
Kaum macht man´s richtig , gehts´s
My Video Tutorials on Youtube: https://www.youtube.com/channel/UCoe3B ... p8Q/videos
My FreeCAD Stuff on Hidrive: https://my.hidrive.com/share/qr3l1yddy6#$/
User avatar
bill
Posts: 337
Joined: Fri Jan 09, 2015 9:25 pm

Re: ESC button in Sketch

Postby bill » Fri Sep 07, 2018 1:02 pm

ESC used to close SKETCH here is uneeded and a slight pain!

Alt-C or the CLOSE button are sufficient!
Alt-C_ForClose.png
Alt-C_ForClose.png (22.48 KiB) Viewed 344 times
wmayer
Site Admin
Posts: 13282
Joined: Thu Feb 19, 2009 10:32 am

Re: ESC button in Sketch

Postby wmayer » Fri Sep 07, 2018 2:30 pm

But it's standard behaviour that with ESC you close/cancel a dialog.
Jee-Bee
Posts: 1355
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: ESC button in Sketch

Postby Jee-Bee » Fri Sep 07, 2018 2:52 pm

That's exactly the point with sketcher. for every action done in a workbench, the sketch is the only one what have a action in a action.

if creating a feature in part design i get into a body but a body don't have a dialog and don't need it. so when creating a extrude it is only possible to go out of the extrude. after that it is finished.
If create a sketch a dialog opens what is nice because it gives more info other cad software don't give... then i create a line it opens a dialog (too).
when canceling the line it shouldn't cancel the sketch at all... but that is what happens when canceling is slow or fails the first (number of) times

I would almost say the sketcher is the only feature what is his workbench...
that's why the sketcher need some special treatment!!
mlampert
Posts: 1014
Joined: Fri Sep 16, 2016 9:28 pm

Re: ESC button in Sketch

Postby mlampert » Mon Sep 10, 2018 3:11 am

Note that I posted PR-1656, it does not change the behaviour of Escape, so that discussion is still ongoing.

What it does though is ensure that the Sketcher behaves the same if one has just clicked on a tool in the task bar or not. So if one presses the "Create a rectangle" tool and then immediately press Escape - then the tool gets cancelled, not the entire Sketcher. This is the same behaviour as if one had actually used the tool to create a rectangle (or two) and then press Escape.
abdullah
Posts: 2590
Joined: Sun May 04, 2014 3:16 pm

Re: ESC button in Sketch

Postby abdullah » Fri Sep 28, 2018 2:08 pm

chrisb wrote:
Sun Sep 02, 2018 4:52 pm
Created ticket issue #3579.
It would appear to me that the perceived problem was already solved here:

https://forum.freecadweb.org/viewtopic. ... 20#p255406

Do we still know to strip the ESC from closing the Sketcher?
chrisb
Posts: 11420
Joined: Tue Mar 17, 2015 9:14 am

Re: ESC button in Sketch

Postby chrisb » Fri Sep 28, 2018 10:15 pm

abdullah wrote:
Fri Sep 28, 2018 2:08 pm
It would appear to me that the perceived problem was already solved here:

https://forum.freecadweb.org/viewtopic. ... 20#p255406

Do we still know to strip the ESC from closing the Sketcher?
That is indeed still open. The solved issue was an inconsistency. The bigger discussion from the beginning of this thread was to eliminate ESC from closing sketcher and assign some other key like Shift+Esc or Ctrl+Esc to close it.
mlampert
Posts: 1014
Joined: Fri Sep 16, 2016 9:28 pm

Re: ESC button in Sketch

Postby mlampert » Fri Sep 28, 2018 11:58 pm

One could argue that, because there isn't actually a "Cancel" from the sketcher - the only valid exit would be "OK" with its "Enter" shortcut - because regardless of what you do, your changes are already applied and will remain applied.
wmayer
Site Admin
Posts: 13282
Joined: Thu Feb 19, 2009 10:32 am

Re: ESC button in Sketch

Postby wmayer » Sat Sep 29, 2018 11:12 am

Just create a dialog with Qt Designer and change the dialog button box to have only the OK button. Invoke the dialog and press ESC. The dialog will still disappear. The reason for this behaviour is that in QDialog::keyPressEvent it's not needed that a button with "reject role" must be present.

So, the current behaviour of the task panel is the same as with Qt's implementation and IMO we shouldn't change it. And when especially talking about the sketcher dialog then we even have the "Close" button (i.e. a button with reject role) so that a user must expect that when clicking on the dialog and pressing ESC will close it. Using some non-standard key combinations like Shift+ESC or Ctrl+ESC would be quite confusing. Especially Ctrl+ESC is already reserved on Windows to open the Start menu.

Now, the likelihood that someone closes the sketcher by accident has reduced a lot with mlampert's PR because the 3d viewer will have the focus and not the dialog any more.

Btw, in sliptonic's video he exactly complained about the opposite. When using the transform tool then there is an OK but not a Close/Cancel button and he complained that when pressing ESC the dialog didn't disappear.


Code: Select all


/*! \reimp */
void QDialog::keyPressEvent(QKeyEvent *e)
{
    //   Calls reject() if Escape is pressed. Simulates a button
    //   click for the default button if Enter is pressed. Move focus
    //   for the arrow keys. Ignore the rest.
    if (e->matches(QKeySequence::Cancel)) {
        reject();
    } else
    if (!e->modifiers() || (e->modifiers() & Qt::KeypadModifier && e->key() == Qt::Key_Enter)) {
        switch (e->key()) {
        case Qt::Key_Enter:
        case Qt::Key_Return: {
            QList<QPushButton*> list = findChildren<QPushButton*>();
            for (int i=0; i<list.size(); ++i) {
                QPushButton *pb = list.at(i);
                if (pb->isDefault() && pb->isVisible()) {
                    if (pb->isEnabled())
                        pb->click();
                    return;
                }
            }
        }
        break;
        default:
            e->ignore();
            return;
        }
    } else {
        e->ignore();
    }
}
mlampert
Posts: 1014
Joined: Fri Sep 16, 2016 9:28 pm

Re: ESC button in Sketch

Postby mlampert » Sat Sep 29, 2018 8:22 pm

wmayer wrote:
Sat Sep 29, 2018 11:12 am
Just create a dialog with Qt Designer and change the dialog button box to have only the OK button. Invoke the dialog and press ESC. The dialog will still disappear. The reason for this behaviour is that in QDialog::keyPressEvent it's not needed that a button with "reject role" must be present.
You make a compelling argument - given that convention we probably should not mess with it.