[JS] Avoid multiple instantiation of pallets

Hi all

I feel so dumb asking such a stupid question, but I really can't get it to work. I have a simple dialog (a pallet). Thing that is user clicks several times, exits windows script much. I want to check for a former launched palette.

I tried everything such a global variable to change onShow and onClose (isRunning = false), private variables.

Any clue?

#targetengine 'demo'

var myDialog = (function(){
    var w = new Window('palette');
    return{
        show:function(){
            w.show();
        }
    }
})();

myDialog.show();

Option 1: Global Variable

#targetengine 'demo'

var isRunning = false;

var myDialog = (function(){
    var w = new Window('palette');

     w.onShow = function(){ isRunning = true; }

     w.onClose = function(){ isRunning = false; }

    return{
        show:function(){
            if(!isRunning) { w.show(); }
        }
    }
})();

myDialog.show();

Option 2: private variable:

#targetengine 'demo'



var myDialog = (function(){
     var isRunning = false;
    var w = new Window('palette');

     w.onShow = function(){ isRunning = true; }

     w.onClose = function(){ isRunning = false; }

    return{
        show:function(){
            if(!isRunning) { w.show(); }
        }
    }
})();

myDialog.show();

I can't operate if the palette is not executed if already done. I tried to check for existence of point of dialogue as in this page too, but it's not helping: http://kelsocartography.com/scripts/scripts/nvkelso/registrationButtons.jsx

DRM for information. I am sure that it is so obvious.

Loïc

Actually, I guess that's not so strange. You redo your variable to each invocation, so isRunning myDialog is wrong every time. Simply adding a check to see if there is already some myDialog prevents it to run two at once:

#targetengine 'demo'

var myDialog = myDialog || (function(){
     var isRunning = false;
    var w = new Window('palette');

     w.onShow = function(){ isRunning = true; }

     w.onClose = function(){ isRunning = false; }

    return{
        show:function(){
            if(!isRunning) { w.show(); }
        }
    }
})();

myDialog.show();

But, I think that you will have the same problems that I showed in my first post with things does not when you run later in the same session.

Tags: InDesign

Similar Questions

  • How to avoid multiple instances of the application

    Hello

    I would like to know how I can to avoid multiple instances of my request, my application have an option to "invoke later" which will awaken the application after xx minutes but where the user clicks on the icon of the application, for example, a few seconds before he must wake up he will see 2 instances open my application.

    Currently, the work around I did is check at every opening, if there is already an open instance and if so to 'kill' later, but I would like to know if there is a more elegant way to do it.

    THX.

    You create a new ApplicationDescriptor - you say the BlackBerry OS that it is a new Application.

    If you use this method, and then the user clicks on the new icon, they will get also running two instances.  Here is a code that restarts the application 'running', that I think that it what you want.

    ApplicationDescriptor current = ApplicationDescriptor.currentApplicationDescriptor ();
    ApplicationManager.getApplicationManager (.scheduleApplication) (current, System.currentTimeMillis (+ 2001), true);
    System.Exit (0);

  • Avoid multiple paths RPD

    Hello
    I have following problem. I have 3 tables: A, B, C in my business model diagram they are mapped as:

    A-> B
    A-> C

    Now, I have to insert an additional mapping B-> C.

    When I save the RPD it gives me following error:

    Multiple paths between A and C. How can I avoid this cycle?

    Thank you

    Giancarlo

    Hi user,
    OBIEE does nt support o-ring.
    In this case, create a table alias for c then give mapping between c b and alias.

    A-> B-> C (alias)
    A-> C

  • How to avoid multiple simple clicks in the Structures of the event

    I use the event structures in my program and I want to avoid the case when pressed by mistake on the button to click several times, because if the user presses the button to click several times the event is logged repeatedly and funtion within 'Change of value' is repeated several times as well. I want to avoid this scenario.

    Can someone please help in this regard.

    Well, there is the "Lock Front Panel up to that end case of event.  You may also disable the button until a timeout occurs.  Another option if you have LabVIEW 2013 or later version is to limit the number of event (option just below the locking of the front panel in the dialog box change events).

  • Avoid multiple calls to the same table in SQL

    Hi team,

    can anyone help me on a technical level with the SQL below.

    SELECT MOR. ACE BLEI_CK BLEI_CK FC_CMC_BLBL_BILL_SUMM INNER JOIN ST_ALL_IFP_MEDCR_SUPPL_STG STG MOR ON MOR BLEI_CK = STG. BIL_ENTY_CK AND MOR. BLBL_PAID_STS <>'3' AND MOR. BLBL_DUE_DT = (SELECT MIN (BLBL_DUE_DT) FROM FC_CMC_BLBL_BILL_SUMM WHERE BLEI_CK =. MOR BLEI_CK AND BLBL_PAID_STS <>' 3') INNER JOIN FC_CMC_BLDF_BL_DEFINE BLDF on MOR. BLEI_CK = BLDF. BLEI_CK AND to_date (January 17, 2012 20:32:25 "," MM/DD/YYYY hh24:mi:ss') BETWEEN BLDF. BLDF_EFF_DT AND BLDF. BLDF_TERM_DT WHERE MOR. BLBL_DLNQ_DT + (BLDF. (BLDF_GRACE_PER-2) < to_date (January 17, 2012 20:32:25 "," MM/DD/YYYY hh24:mi:ss') GROUP OF MOR. BLEI_CK ORDER BY BLEI_CK

    Here, the FC_CMC_BLBL_BILL_SUMM table is called two times in the same query. How to avoid this problem by using any means or Analytics

    Thank you

    something like this:

    WITH Boop AS (SELECT BLEI_CK

    BLBL_DUE_DT

    BLBL_DLNQ_DT

    ROW_NUMBER() over (ORDER BY BLBl_DUE_DT DESC BLEI_CK PARTITION) AS date_rank

    OF FC_CMC_BLBL_BILL_SUMM

    WHERE BLBL_PAID_STS <> '3')

    SELECT MOR BLEI_CK AS BLEI_CK.

    MOR

    INNER JOIN ST_ALL_IFP_MEDCR_SUPPL_STG ON (MOR. BLEI_CK = STG STG BIL_ENTY_CK)

    INNER JOIN FC_CMC_BLDF_BL_DEFINE BLDF ON (MOR. BLEI_CK = BLDF. BLEI_CK)

    WHERE MOR. DATE_RANK = 1

    AND MOR. BLBL_DLNQ_DT + (BLDF. BLDF_GRACE_PER-2)< to_date('01/17/2012="" 20:32:25','mm/dd/yyyy="">

    AND to_date (January 17, 2012 20:32:25 "," MM/DD/YYYY hh24:mi:ss') BETWEEN BLDF. BLDF_EFF_DT AND BLDF. BLDF_TERM_DT

    GROUP OF MOR BLEI_CK.

    ORDER BY BOOP. BLEI_CK

    /

    HTH

  • Avoid multiple BPM projects

    Hello

    I am creating a BPM application and I have 4 human tasks in this application. When I create a form ADF for each task, eash task creates a new project. Can I have a single project for all these tasks of Thomas with different forms of the ADF?

    Thank you
    Lakshmi.

    Hey Lakshmi,

    I've just uploaded a video (http://youtu.be/bpVVpDJLE1o) that shows you how to put forms for multiple human tasks in a single project ADF.

    Hope this helps,
    Dan

  • Avoid the multiple join

    Hi all

    How can we avoid multiple join for queries like this

    Select temp1 a, temp1 a.x, b.x, c.text a, c to temp2 where a.y = c.y and b.y = c.z

    So, it will scan temp1 twice. Can we do this to analyze only once

    application of warehouse that joins the tables more then 5-6

    Well, it certainly changes the circumstances ;)
    However: put you it in a small testcase, everyone can play and test with, thanks for this anyway.

    If am understanding right

    What I wanted to point out, is that you will need to run tests on your own configuration (equipment/sets/distribution, etc.)
    My little test notes (on my setup, which is not a warehouse at ;)) there's still nothing wrong with a full table scan + hash join.) It would be 'better' in 'my cases '.
    But "your case" is quite different.
    One thing I do know of: your hardware will be better than my old Windoze pc by orders of magnitude.
    Optimizer considers several aspects (selectivity of cpu/data etc.) that will completely differ from my plans.
    You should compare the different options you have in tracing the respective motions, you think that you could use, each of them and compare the results you get. Choose the one that suits.
    So: you are about to go to the next level:
    Always test and measure these things, different scenario that are available.
    As there is no generic datamodel, it is not a generic 'alter system set fast = true' option (yet).
    Optimizer tries to keep track of each scheme and did the best that he can do, but it's also been polished every version.
    Therefore: never take results things for granted.
    Now I could say, just as everyone else: 'approach 'A' works better. Period. "(And create a"Silver Bullet"myth and selling lots of books perhaps ;))
    But we'll just have to say: ' approach 'A' works best, on my setup, using dataset X to version Y etc.. and I tested these scenarios, here are the results to which it will be clear why I chose approach 'A'. '. Your results may be different, because I don't know your configuration. "

    This is just good old: 'it depends' (after you ask 'why?')
    And then you will need to dive into your system to "understand why."
    You will need to test and measure.
    trace/tkprof and/or AWR is here to help you with it.

    Sweeping two large table in one of them was sweeping twice for this.

    What is today a large table? The number of records? What is the index? Is there present asymmetric data?
    I'm just pointing to this point, because all that comes to play.
    You should ask a lot of questions in order to get a grip/overview.
    Keep an open mind.

    So, I was looking for as an alternative to avoid twice scan

    Maybe you don't even need to. Perhaps optimizer has done the best it could do for you.
    But please, if you want to be sure: test, trace/tkprof and you will get your answer.
    If you are unsure of the results you can always post and ask here or the DBA (and some authorities of Tuning that hang out there as well this subject ;)) @ the [General Forum database | http://forums.oracle.com/forums/forum.jspa?forumID=61])

    Enclosing: tips are usually a path of last resort. At least: on my PC sloppy, they are always ;)

  • HP LaserJet Enterprise 600 M60: Avoid duplicate copies of HP LaserJet Enterprise 600 M602

    Hello

    We have several printers HP LaserJet Enterprise 600 M602 installed at different locations, printers at different locations are connected via USB to a berth to, when a use goes from 1 location to the other place and docks of the toughpad in dock station... another copy of gets printers installed copy 1 copy 2

    We don't want no copies of printers is installed because on all locations, we have same model...

    Can you please advice how to avoid multiple copies and a generic installed printer prints on all sites...

    Kind regards

    Atif

    Since they are attached USB you don't have any options.

    Each USB printer is recognized as a different device, so you can't print to one with the installation of the driver for another.

    If my post is solved your problem and click the accepted as button solution under him.

    In order to thank a Tech for a post click the thumbs up button under the post.

    You can even click on the two keys...

  • Using a zoom on multiple slides area

    In Captivate 4, I would like a zoom area allows to highlight a series of actions that occur in a window.  This sequence has been captured by Captivate as several slides, so I created areas of focus on all of the slides (using the copy/paste) to zoom in the same area and display it in the same area.  On the first slide, I left the Zoom for the value default 0.8 second and on the following slides set it to 0,0 in the hope that the zoom area opens instantly, giving the appearance of a single zoom which remains open to all slides area.  But during playback (if an overview or a published project), the zoom animation happens at the beginning of each slide.  How can I avoid multiple zoom animations and just let the open zoom area?

    Thanks in advance,

    Paul

    Hi Paul

    So far, I came up with two possible solutions. But I'm not sure no more one of them will do what you want.

    1. you can use the solution you tried where you see the really fast zoom to occur, but mask the zoom back by inserting an image or select the box in front of the area to hide so that only the short zoom occurs.

    2. you can use a slidelet that steps actions to occur in series on the slidelet timeline. In this way the zoom happen once. Here again, you could do the same thing by combining simply objects and images on a single slide and fail or to renounce the slidelet.

    From what you describe, you want the type of zoom provided by Camtasia Studio.

    Click here to see the zoom of Captivate

    Click here to see the zoom of Camtasia

    See you soon... Rick

    Useful and practical links

    Captivate wish form/Bug report form

    Certified Adobe Captivate training

    SorcerStone blog

    Captivate eBooks

  • How can I remove / delete an email account in Thunderbird?

    My account gmail is a catch all for some email accounts, so I don't need to do them individually on Thunderbird. To avoid multiple copies the same mails - how to DELETE/REMOVE/CLOSE an email account on Thunderbird?

    Select the account that is unwanted in the left pane of the folder. Right click, select "settings".

    The account settings pane appears, with the selected account has highlighted. At the bottom of the pane is a button labeled account Actions, which, once clicked will show an option to delete account. You can select and remove as many accounts as you want, but note that you will not be allowed to delete the default account. You must first designate a different default account.

  • WSN-9791 frequency selection and interference

    WSN-9791 indicates that it can operate on the 2.4 GHz band channels 11-24 (I'm guessing that USA is limited to 11).  How to avoid multiple interference OR WSN, in the same neighborhood?  Is there a way to set or determine the channels that the network is working in?  For example, with the 802.11 standard common internet hubs can fix them to use one of these 11 channels.

    Thank you

    Garrett

    Hey Garret.

    You are right that channels 25 and 26 are outside the range of 802.11, but they cannot be used for the same reason that you can't go to channel 11 for 802.11 here in the United States.

    Also, for the gateways in the same neighborhood, you must assign different channels.  Gateways running on the same channel in the same vicinity will cause problems for both networks.

    The questions keep coming!

    Kevin

  • LabWindows - how to detect the unlock key?

    My application uses a reminder with EVENT_KEY_PRESS to detect the function keys on the keyboard. A routine is executed depending on the feature key. It all works very well.

    Is there a way to tell when the key is out?

    The goal is the routine to run only once and not repeated if the user is now pressed the button for an extended period of tiime.

    Ideas are appreciated,

    Thank you

    Scott T.

    Note: You can also use this method to avoid multiple keypress for any key events.

    Scott used the example of function keys.  If you also want to avoid entering repeated alphanumeric keys, 1 return your reminder of the textbox to swallow the event, is not a new key pressure.

    A new .c file (to replace the one of my previously posted project) is attached that illustrates this.

  • How to pause an auto update

    I am currently in the middle of a download of automatic update of Windows (for Vista). I have a dial-up internet access downloads of this nature tend to be very slow. At the same time I am trying to download another (big) program via internet. Progress on the other this program are practically at a standstill, and I think that the current windows download may be an obstacle to my another download. In view of this, I want to 'Break' of my Windows activity until I can complete the other. How can I do this (I have try click left/right clicking on the download icon of Windows in the lower right task bar but nothing appears to facilitate a break). I see that this option for a break is not available w/XP, is it the same with Vista? If so, what would happen if I changed "automatic updates for Windows'"Manual updates for Windows"- this would allow me to pause. If the manual conversion take effect immediately w/the current would download?

    Once the downloads have started - if they are started automatically or manually, there is no break. If all goes well, it is too much and the process will be completed and then the other your download should go faster.  Just be patient and the next time, try to avoid multiple downloads - perhaps you may need to change the download of the scheduled update calendar at a time where you are still less likely to use the computer.

    Sorry, but this is the way which he he.

    Good luck!

    Lorien - MCSA/MCSE/network + / has + - if this post solves your problem, please click the 'Mark as answer' or 'Useful' button at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.

  • single instance of application

    Hello

    I ' am, development of a web application, in javascript, I use "blackberry.app.requestBackground ();".

    I would like to know how I can to avoid multiple instances of my request.

    Excuse me for my bad English

    Concerning

    If your application is in the background and click on the icon to the home screen of your application, it will be simply reduced upwards in the foreground.  It will not run multiple instances of the same application.

  • Scroller of broken blackBerry Smartphones

    is there anyway I can access without using the scrolling stuff on my bb curve 9300?

    Please avoid multiple of the same message. Check the other post for answer.

Maybe you are looking for