Slider + ShiftKey
-
@ulrik said in Slider + ShiftKey:
@Lindon if I remember this is normal keys
obj.keyCodeand special keys
obj.specialKeywell I have no idea what you are doing there....
so this code:
inline function onVolumeKeyPress(obj) { Console.clear(); Console.print("keypress event"+ trace(obj)); }generates this on mousedown:
Interface: keypress event{ "isFocusChange": true, "hasFocus": false }and if I press shift and mouse down - I get exactly the same thing...so nothing useful
-
@Lindon I can only log:
"isFocusChange": true, "hasFocus": falsefrom a slider keypresscb
that must be a bug or me doing something wrong as usual?
-
I'm pretty sure I added something like Content.isShiftDown. I'll check when I'm at computer in a little while.
-
A modifier key is not propagated as key press event, so you're barking up the wrong tree.
Using a broadcaster that listenens to mouse events is super trivial:
const var bc = Engine.createBroadcaster({ "id": "ShiftWatcher", "colour": -1, "args": ["component", "event"] }); bc.attachToComponentMouseEvents("Knob1", "Clicks, Hover & Dragging", "watch shift events"); /** just a dummy function that colours the knob based on whether the shift key is pressed or not. */ bc.addComponentPropertyListener("Knob1", ["itemColour", "itemColour2"], "change the colour", function(index, component, event) { return event.shiftDown ? Colours.red : Colours.blue; }); -
@Lindon I can see the slider is not working as a panel, this is an old excerpt that I used before for panels
Assigning a slider and try to log the "obj" will crash HiseHiseSnippet 1172.3ocsV8+SaaDE+Lf2p8VmVk1e.tLoJGsRHosqchHzBDBUQLnQDJp7Kq5h8Kw23xcV1mgFMw+y6+fs2c1IwIjvlhFV.h6du289799qahL.RSkIDKmKFGCDqu0t2XgJpUDkIHcNhX8DaNSDJEjCGGSSSgPhk0luWS0xYKh46u90CobpH.lcEgbojE.+FaDSM61tMOgw4GSCgKXiJw8aZ1IPJZI4xLDIaZWiDSCtlNDNipYaCah0W0NjojI8TTEjRr15PY33dQxaE47eIKk0mC5C0I8vGJ+5ik7PMh02RZEw3gcmXwoD7U5Ny92L29+A6SYgro2OyO78FBdyjnr+vZi4g2lyAu5kgWsRvaIPxpDj1JGROytWPBKVMihFOeicGgBRFPQ2dYnjyKYiez1tkD4PnpNhdMbbBdXpD9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YMj4mWCYd6ZHy6VCY9kGTF891GjojixKGvK511z4yxpsfhYVlrPx+.Tal98A -
@Christoph-Hart Ok, so the old concept KeyPress is not valid for at least sliders?
-
@d-healey said in Slider + ShiftKey:
I'm pretty sure I added something like Content.isShiftDown. I'll check when I'm at computer in a little while.
well this would be the simplest - so if you can look it up that would be great
component.isShiftDown() < -- doesn't appear to be it...
-
That hasn't changed. Modifier keys (alt, shift, ctrl) are never propagated as key strokes (not just for sliders, everytime), otherwise a key stroke like "ctrl+c" would always be two calls and you need to discard the first.
Lindon wants to know whether a modifier key is pressed while dragging the mouse, so the logical solution is to use a mouse event broadcaster.
-
@Christoph-Hart Ok, thanks!
-
@Christoph-Hart said in Slider + ShiftKey:
A modifier key is not propagated as key press event, so you're barking up the wrong tree.
Using a broadcaster that listenens to mouse events is super trivial:
const var bc = Engine.createBroadcaster({ "id": "ShiftWatcher", "colour": -1, "args": ["component", "event"] }); bc.attachToComponentMouseEvents("Knob1", "Clicks, Hover & Dragging", "watch shift events"); /** just a dummy function that colours the knob based on whether the shift key is pressed or not. */ bc.addComponentPropertyListener("Knob1", ["itemColour", "itemColour2"], "change the colour", function(index, component, event) { return event.shiftDown ? Colours.red : Colours.blue; });so to add multiple sliders i just say this?
bc.addComponentPropertyListener(["Knob1","Knob2","Knob3"], ["itemColour", "itemColour2"], "change the colour", function(index, component, event)and this?:
bc.attachToComponentMouseEvents(["Knob1","Knob2","Knob3"], "Clicks, Hover & Dragging", "watch shift events"); -
Sure. However then you need to figure out which component is currently dragged so you need to use the
indexandthisobject in the function (also you need to check theevent.dragflag.const var bc = Engine.createBroadcaster({ "id": "ShiftWatcher", "colour": -1, "args": ["component", "event"] }); /** No need to define multiple arrays... */ const var bcTargets = ["Knob1", "Knob2", "Knob3"]; bc.attachToComponentMouseEvents(bcTargets, "Clicks, Hover & Dragging", "watch shift events"); /** the index can be used to check the component argument against the `this` object of the function (= the component array). */ bc.addComponentPropertyListener(bcTargets, ["itemColour", "itemColour2"], "change the colour", function(index, component, event) { // index is -1 if you don't pass in an array so this will cover all cases... var isSameComponent = index == -1 || (this.length > 0 && this.indexOf(component) == index); return isSameComponent && event.drag && event.shiftDown ? Colours.red : Colours.blue; }); -
@Christoph-Hart thanks.
-
The broadcaster is nice, but overkill for this simple task.
In one of my scripts I'm using
Content.isCtrlDown()and it does the trick nicely. I don't know if this is just a feature in my fork or if it was merged into the main codebase. Either way if there is demand I could add a .isShiftDownand.isAltDownfunction too.