Hi,
In qcad, when we keep Shift key pressed, we have selection with mode Add and when we release it we are back to selection with mode replace.
How can I programatically switch with this 2 modes ?
Thanks.
switch between mode selection
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files, scripts and screenshots.
Post one question per topic.
Re: switch between mode selection
For example when using RDocumentInterface::selectEntity, you can pass true as second parameter to add to selection, false to replace the selection:
Code: Select all
documentInterface.selectEntity(entityId, true);
Re: switch between mode selection
Hi,
We don't want to do the selection programatically, we want have a button that switch with the 2 modes, the user can employ it and his selection takes in consideration his choice, same as scenario of shift key.
Unless you see we are forced to do it programatically : detect when user selection change; with having the selection before and the new selection, and generate programatically a new selection up to user choice mode.
We don't want to do the selection programatically, we want have a button that switch with the 2 modes, the user can employ it and his selection takes in consideration his choice, same as scenario of shift key.
Unless you see we are forced to do it programatically : detect when user selection change; with having the selection before and the new selection, and generate programatically a new selection up to user choice mode.
Re: switch between mode selection
Perhaps, what you are looking for is something like the persistent selection mode of QCAD in which the user can click the entities to select or deselect without using shift. To deselect everything, Select > Deselect all can be used.
You can activate this mode as follows:
Or in QCAD under Edit > Application Preferences > Graphics View > Appearance > Persistent Selection.
You can activate this mode as follows:
Code: Select all
RSettings.setValue("GraphicsView/PersistentSelection", true);
Re: switch between mode selection
This is not really what I need.
In context that our user works with keyboard we don't have probleme, because we know when he will want to select with add mode he will press on key shift.
In other context when the user works with tablet, and then the way pressing on key shift not exists, we need to offer him a tool that does the same thing as keyboard shift, meaning switch to mode add selection, or notify script select that mode is changed.
In context that our user works with keyboard we don't have probleme, because we know when he will want to select with add mode he will press on key shift.
In other context when the user works with tablet, and then the way pressing on key shift not exists, we need to offer him a tool that does the same thing as keyboard shift, meaning switch to mode add selection, or notify script select that mode is changed.
Re: switch between mode selection
Thanks for your clarification.
This is not easily achievable, unless your operating system has a way to emulate a shift key press.
The shift key / selection behaviour is implemented in scripts/DefaultAction.js.
I've refactored this class to make it easer to override this behaviour. You can find the refactored version at:
https://github.com/qcad/qcad/blob/maste ... tAction.js
You can override the default action, e.g. as "MyDefaultAction" as follows:
You can then initialize QCAD to use your own default action:
This is not easily achievable, unless your operating system has a way to emulate a shift key press.
The shift key / selection behaviour is implemented in scripts/DefaultAction.js.
I've refactored this class to make it easer to override this behaviour. You can find the refactored version at:
https://github.com/qcad/qcad/blob/maste ... tAction.js
You can override the default action, e.g. as "MyDefaultAction" as follows:
Code: Select all
include("scripts/DefaultAction.js");
function MyDefaultAction(guiAction) {
DefaultAction.call(this, guiAction);
}
MyDefaultAction.prototype = new DefaultAction();
MyDefaultAction.prototype.getAddToSelection = function(shiftPressed) {
return (your own condition here) || DefaultAction.prototype.getAddToSelection.call(this, shiftPressed);
};
Code: Select all
setSettingsValue("NewFile/DefaultAction", "scripts/...../MyDefaultAction.js", true);
Re: switch between mode selection
Thanks for your help