[texworks] Help please with Integer constants and use in messageboxes
Paul A Norman
paul.a.norman at gmail.com
Sat Apr 24 13:36:44 CEST 2010
I have found that the messagebox with 1024 can be suppressed by
setting its result to null as below.
Should I be setting the result of the script to null?
Paul
var fileList = TW.app.getOpenFileNames();
var fileNames = fileList.join("\n \n")
answer = TW.information(null, "file names", fileNames);
answer = null;
On 24 April 2010 17:43, Paul A Norman <paul.a.norman at gmail.com> wrote:
> Thanks for that Stefan the correct direct link was a great help,
>
> Indeed one of my integer constants had been depreciated.
>
> Still it seems that the correctly named integer constants are not
> available to QTScript engine yet.
> Using the real/current constants' names still produces this kind of error:
>
> Sat 24. Apr 17:16:52 2010 Uncaught exception at
> D:/LaTeXPortable/LatexUtils/TeXworks/TeXworks/config/scripts/Js
> Trials/experiments.js:12:
> ReferenceError: Can't find variable: RestoreDefaults
>
> We can use the hex form, both in the messagebox call, and in the
> SWITCH/case statements - but it looks a bit clumsy, and hard to
> re-edit later.
>
> Strangely at the end of running this script (below) I always get a
> unexpected message box with "1024" as the message.
>
> Should I put this up as an Issue?
>
> Paul
>
> // TeXworksScript
> // Title: Trial Script
> // Description: Experiments
> // Author: Paul A Norman
> // Version: 0.1
> // Date: 2010-03-18
> // Script-Type: standalone
> // Context: TeXDocument
>
> // Experiment
> var chosen = TW.information(null, "Some Text", "Some other text",
> 0x08000000 | 0x00020000 | 0x00400000,0,2);
>
> // 0- RestoreDefaults default button, 2 - cancel button
> switch (chosen)
> {
> case 0x08000000:
> TW.information(null, "RestoreDefaults", "RestoreDefaults -
> 0x08000000");
> break;
>
> case 0x00020000:
> TW.information(null, "NoToAll", "NoToAll - 0x00020000");
> break;
>
> case 0x00400000:
> TW.information(null, "Cancel", "Cancel - 0x00400000");
> break;
>
> default:
> TW.information(null, "Default", chosen);
> } // End/ switch
>
> TW.information(null, "Returned Value Decimal?", "Returned
> Value - Decimal? : " + chosen);
>
> On 24 April 2010 00:03, Stefan Löffler <st.loeffler at gmail.com> wrote:
>> Hi,
>>
>> Am 2010-04-23 13:55, schrieb Paul A Norman:
>>> Sorry to have to bring this up I should have been able to work this
>>> out, but I've been looking in
>>> http://ldc.usb.ve/docs/qt/qmessagebox.html trying to get dialogs to
>>> work with buttons and capture the return value.
>>>
>>> Am I looking in the right place under QT please?
>>>
>>
>> Well, it's not the official Qt documentation, and it seems to be for a
>> fairly old version (4.1) which is not supported by Tw, anyway.
>> The better place to start would be
>> http://doc.trolltech.com/4.3/qmessagebox.html#StandardButton-enum where
>> we have the official 4.3 docs. Maybe new constants have been added
>> since, but in the interest of compatibility you should only use those.
>>
>> HTH
>> Stefan
>>
>
More information about the texworks
mailing list