Hello,
How do you write this event "onAltClick" or "onControlClick"? I know it's possible, I saw this on other scripts. Any idea?
onAltClick or onControlClick
Moderator: Paul Tuersley
-
- Posts: 81
- Joined: November 27th, 2012, 6:41 am
Code: Select all
function onTestButtonClick(ev)
{
var b = ev.target;
if (!(b instanceof Button)) return;
var modState = ScriptUI.environment.keyboardState;
if (modState.shiftKey) alert('nicely shifted !')
else if (modState.altKey) alert('Alt+Click not supported !!!')
else alert("You just plain-pressed a plain button.");
};
var pal = new Window("palette", "test", undefined, {resizeable: true});
pal.content = pal.add("group{alignment: ['left', 'top'], btn: Button{text:'test', size: [60,20]}}");
pal.content.btn.addEventListener('click', onTestButtonClick);
pal.center(); pal.show();
-
- Posts: 81
- Joined: November 27th, 2012, 6:41 am
i dont know how to do that.
The thing is that if you use a mouse event handler, the shiftKey should be pressed BEFORE the mouse enters the button region, and it is not quite what a user expects.
There is an event type for the mouse entering the button's region ('mouseover'), leaving the button's region ('mouseout'), moving above the button's region ('mousemove'), but nothing for staying idle over the button: it is not an event, just a state.
So the event should be a keyboard event (the shiftKey is pressed) and upon that event determine if the key is above the button: no idea how to do that.
There is a KeyboardEvent object (never used), but how to read the mouse state afterwards, still no idea.
If there is a solution to that, you should find it in the Javascript Tool Guide > Event Handling, and if you find it, please come back and post
Xavier.
The thing is that if you use a mouse event handler, the shiftKey should be pressed BEFORE the mouse enters the button region, and it is not quite what a user expects.
There is an event type for the mouse entering the button's region ('mouseover'), leaving the button's region ('mouseout'), moving above the button's region ('mousemove'), but nothing for staying idle over the button: it is not an event, just a state.
So the event should be a keyboard event (the shiftKey is pressed) and upon that event determine if the key is above the button: no idea how to do that.
There is a KeyboardEvent object (never used), but how to read the mouse state afterwards, still no idea.
If there is a solution to that, you should find it in the Javascript Tool Guide > Event Handling, and if you find it, please come back and post

Xavier.