Are the keyboard strokes trapped by Python or C.
Where in codebase would this appear if I wanted to extend to a Custom View? Lets say keystroke V,C would provide a side view tilted 5 degrees towards the viewer (which would intentionally change the shading gradients on the model).
Keystroke Trapping: Python or C
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Keystroke Trapping: Python or C
I do not know about Python, at c++ level the view provider (src/Gui/ViewProvider.cpp) provides you with key presses. Then this is inherited, for example at sketcher level it is (src/Mod/Sketcher/Gui/ViewProviderSketch.cpp):
I never use Python, but searching in Draft WB, I found this:
It may be or not the real deal...
Code: Select all
bool ViewProviderSketch::keyPressed(bool pressed, int key)
Code: Select all
DraftGui.py: def keyPressEvent(self, event):
Re: Keystroke Trapping: Python or C
that is for the view provider. I am not sure if what you want is to make a new command and assign such a shortcut. Because those are part of the command then. Example (CommandCreateGeo.cpp):bill wrote: ↑Thu May 24, 2018 12:16 pm Are the keyboard strokes trapped by Python or C.
Where in codebase would this appear if I wanted to extend to a Custom View? Lets say keystroke V,C would provide a side view tilted 5 degrees towards the viewer (which would intentionally change the shading gradients on the model).
Code: Select all
CmdSketcherCreateRectangle::CmdSketcherCreateRectangle()
: Command("Sketcher_CreateRectangle")
{
sAppModule = "Sketcher";
sGroup = QT_TR_NOOP("Sketcher");
sMenuText = QT_TR_NOOP("Create rectangle");
sToolTipText = QT_TR_NOOP("Create a rectangle in the sketch");
sWhatsThis = "Sketcher_CreateRectangle";
sStatusTip = sToolTipText;
sPixmap = "Sketcher_CreateRectangle";
sAccel = "R";
eType = ForEdit;
}
Code: Select all
class Draft_Label(Creator):
"The Draft_Label command definition"
def GetResources(self):
return {'Pixmap' : 'Draft_Label',
'Accel' : "D, L",
'MenuText': QtCore.QT_TRANSLATE_NOOP("Draft_Label", "Label"),
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Draft_Label", "Creates a label, optionally attached to a selected object or element")}
def Activated(self):
self.name = translate("draft","Label", utf8_decode=True)