[javascript FR] Set event.modifier and/or event.shift for Menu events  SOLVED

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: Daniel - PDF-XChange, PDF-XChange Support, Vasyl - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

Mathew
User
Posts: 567
Joined: Thu Jun 19, 2014 7:30 pm

[javascript FR] Set event.modifier and/or event.shift for Menu events

Post by Mathew »

For some scripts, it would be useful to have a way to run the script without a dialog, and have a way to make a dialog show to change options, etc. Currently this can be done by making two separate tools, but it would be very useful for a toolbar or menu script to know if the Ctrl or Shift key was held down while the menu item was selected. This would allow the script to provide one or the other option.

I can't find anything in the JS API saying only field events get those properties, but that's the only time they seem to be filled for PDF XChange(?)

Code: Select all

// test for event.modifier and event.shift

app.addToolButton( {
    cName: 'CtrShiftTest',
    cLabel: "Hold down Ctrl or Shift",
    cExec: 'testCtrlShiftEvent(event);'
});

function testCtrlShiftEvent(evt) {
    let kp = [];
    if (evt.modifier) kp.push("Ctrl");
    if (evt.shift) kp.push("Shift");
    if (!kp.length) kp.push("No");
    app.alert( kp.join(" & ") + " key pressed!");
}
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 10998
Joined: Wed Jan 03, 2018 6:52 pm

Re: [javascript FR] Set event.modifier and/or event.shift for Menu events

Post by Daniel - PDF-XChange »

Hello, Mathew

Ive passed this along to the dev team for review, and will let you know what they have to say here.

Also, unrelated to the question itself, I notice you posted in the Viewer forum, I presume that this question is related to the Editor? Should I move the topic for you?

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 10998
Joined: Wed Jan 03, 2018 6:52 pm

Re: [javascript FR] Set event.modifier and/or event.shift for Menu events  SOLVED

Post by Daniel - PDF-XChange »

Hello again

Ive just heard this was a quick fix!
Ivan wrote:fixed. now "modifier" and "shift" properties will have proper value for every type of event
Hopefully it makes it into the 10.6 release next week, but if not it should be in the one following that.

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Mathew
User
Posts: 567
Joined: Thu Jun 19, 2014 7:30 pm

Re: [javascript FR] Set event.modifier and/or event.shift for Menu events

Post by Mathew »

Daniel - PDF-XChange wrote: Fri May 02, 2025 6:11 pm Also, unrelated to the question itself, I notice you posted in the Viewer forum, I presume that this question is related to the Editor? Should I move the topic for you?
ooOOpps! yes please!
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 10998
Joined: Wed Jan 03, 2018 6:52 pm

[javascript FR] Set event.modifier and/or event.shift for Menu events

Post by Daniel - PDF-XChange »

:)
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com