mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 08:21:24 +02:00
add example of overriding default rightClick behavior
This commit is contained in:
parent
8431ef9b98
commit
b94258f953
2 changed files with 11 additions and 1 deletions
10
examples/controllers/rightClickExample.js
Normal file
10
examples/controllers/rightClickExample.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
var MAPPING_NAME = "com.highfidelity.rightClickExample";
|
||||||
|
var mapping = Controller.newMapping(MAPPING_NAME);
|
||||||
|
mapping.from(Controller.Hardware.Keyboard.RightMouseClicked).to(function (value) {
|
||||||
|
print("Keyboard.RightMouseClicked");
|
||||||
|
});
|
||||||
|
Controller.enableMapping(MAPPING_NAME);
|
||||||
|
|
||||||
|
Script.scriptEnding.connect(function () {
|
||||||
|
Controller.disableMapping(MAPPING_NAME);
|
||||||
|
});
|
|
@ -676,7 +676,7 @@ Mapping::Pointer UserInputMapper::newMapping(const QString& mappingName) {
|
||||||
|
|
||||||
void UserInputMapper::enableMapping(const QString& mappingName, bool enable) {
|
void UserInputMapper::enableMapping(const QString& mappingName, bool enable) {
|
||||||
Locker locker(_lock);
|
Locker locker(_lock);
|
||||||
qCDebug(controllers) << "Attempting to enable mapping " << mappingName;
|
qCDebug(controllers) << "Attempting to " << (enable ? "enable" : "disable") << " mapping " << mappingName;
|
||||||
auto iterator = _mappingsByName.find(mappingName);
|
auto iterator = _mappingsByName.find(mappingName);
|
||||||
if (_mappingsByName.end() == iterator) {
|
if (_mappingsByName.end() == iterator) {
|
||||||
qCWarning(controllers) << "Request to enable / disable unknown mapping " << mappingName;
|
qCWarning(controllers) << "Request to enable / disable unknown mapping " << mappingName;
|
||||||
|
|
Loading…
Reference in a new issue