Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

How to test the state of a "window" (is it open or closed)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to test the state of a "window" (is it open or closed)

    I use a simple menu button that opens a "window" object. The window
    is set to automatically close if you touch elsewhere on the panel.

    However, I find that I and others naturally tend to want to press the
    menu a second time in order to close the menu window.
    In order to toggle the window open or closed you need to be able to
    ask the question "What state is the window currently in?".


    I can use a variable to toggle the state but it is more reliable if you
    can query the object itself.

    Here is my simple code:

    // ---
    // - Toggle the main menu open or closed
    // ---

    // Define a local variable (vl_) to hold the current state of the window.
    var vl_menu_state="";

    // Determine current state of window
    vl_menu_state = ??? <-- what function or method goes here?

    // If open, then close; else it is closed and should be opened
    if (vl_menu_state == "open") {
    // Close the menu window
    {dialog.Object}.closeWindow('WIN_MENU_MAIN');

    }
    else {
    // Open the menu window
    {dialog.object}.showContainerWindow(this,'WIN_MENU_MAIN');
    }



    Ideas are welcome!
    Last edited by parkjammer; 09-18-2014, 03:53 AM.

    #2
    Re: How to test the state of a &quot;window&quot; (is it open or closed)

    So, the menu is in a DIV which is used to show and hide the contents. That DIV has a unique id --- which you'll need to look up (it may not be {dialog.componentName}.V.R1.WIN_MENU_MAIN, it might have a parent DIV that handles the visibility.)

    At any rate, it will have 1 of 3 possible states:
    1. Doesn't exist: $('{dialog.componentName}.V.R1.WIN_MENU_MAIN') === null
    2. Exists, visible: $('{dialog.componentName}.V.R1.WIN_MENU_MAIN').style.display !== 'none'
    3. Exists, hidden: $('{dialog.componentName}.V.R1.WIN_MENU_MAIN').style.display === 'none'

    Hope that helps.
    ---
    Sarah
    Alpha Anywhere latest pre-release

    Comment


      #3
      Re: How to test the state of a &quot;window&quot; (is it open or closed)

      var wObj = {dialog.object}.getWindow('WIN_MENU_MAIN');

      if (wObj.hidden)
      {
      {dialog.object}.showContainerWindow(this,'WIN_MENU_MAIN')
      }
      else
      {
      {dialog.Object}.closeWindow('WIN_MENU_MAIN');
      }

      Comment


        #4
        Re: How to test the state of a &quot;window&quot; (is it open or closed)

        Sara and Dave... very helpful. I'm rebuilding a suite of apps in preparation for a sale. Having focused on core app function in the past, I'm now trying to add little bits of polish.

        Thanks much!

        Look me up at the 2014 Alpha Developer's conference in Boston if you're there.

        Comment


          #5
          Re: How to test the state of a &quot;window&quot; (is it open or closed)

          There are days when I hate both Alpha and javascript. I'll manage to
          create lots of complex things with no particular issue and then burn
          hours on something crazily stupid.

          I have spent many hours (!?!) trying variations of your collective
          suggestions but to no avail.

          The ".hidden" property and the ".style.display" properties simply
          do not respond (or may not exist in the case of ".hidden").

          If by chance you have a moment to look at what I'm doing, here
          are links to my test component, a video, and a screen shot.

          Short Video (URL)
          Component (URL)
          TEST_UX_-_toggle_menu.jpg
          NOTE: these links may not survive more than 3 months from 2014-SEP-20

          Any additional input would be appreciated.

          Thanks.

          Comment


            #6
            Re: How to test the state of a &quot;window&quot; (is it open or closed)

            Allan - You need to assign a name to your window in order for {dialog.object}.getWindow() to work. Open the window properties for the WIN_MENU_MAIN control and enter "WIN_MENU_MAIN" in the Window name property. Then change your if statement to the following:

            Code:
            if (vl_menu_ref1.hidden)
            {
            	// Open the menu window if closed
            	{dialog.object}.showContainerWindow(this,'WIN_MENU_MAIN');
            }
            else
            {
            	// Close the menu window if open
            	{dialog.Object}.closeWindow('WIN_MENU_MAIN');
            }

            Comment


              #7
              Re: How to test the state of a &quot;window&quot; (is it open or closed)

              Allan - Here is a crude way to display the contents of a Javascript object in more than 1 alert dialog (if necessary). This will keep the alert dialog from expanding beyond the height of the screen. Just lower the ctr variable if there is an extra large property causing one of the alert dialogs to get too big.

              Code:
              function printObject(o)
              {
              	var out = '';
              	var ctr = 0;
              	
              	for (var p in o)
              	{
              		out += p + ': ' + o[p] + '\n';
              		ctr++;
              		if (ctr > 24)
              		{
              			alert(out);
              			out = '';
              			ctr = 0;
              		}
              	}
               
               	if (ctr > 0)
               	{
               		alert(out);
               	}
              }
              Do you use the Chrome debugger? It is much easier to set a breakpoint using the "debugger;" directive and then expand the object in the watch window.

              Comment


                #8
                Re: How to test the state of a &quot;window&quot; (is it open or closed)

                Originally posted by DaveF View Post
                Allan - You need to assign a name to your window in order for {dialog.object}.getWindow() to work. Open the window properties for the WIN_MENU_MAIN control and enter "WIN_MENU_MAIN" in the Window name property. Then change your if statement to the following:

                Code:
                if (vl_menu_ref1.hidden)
                {
                	// Open the menu window if closed
                	{dialog.object}.showContainerWindow(this,'WIN_MENU_MAIN');
                }
                else
                {
                	// Close the menu window if open
                	{dialog.Object}.closeWindow('WIN_MENU_MAIN');
                }

                First, thanks much for taking a look. I'll try this shortly.

                My question is... why is the "name" required in this instance? Every
                other object responds based on the ID. The only other circumstance
                I've run into where a name is required is when you have a parent UX
                launching a child UX and then wanting to have the "onPanelActivate"
                event to fire properly.

                While my general coding skills are solid (many languages), my javascript
                is simply "the basics, google, and bend". However, I have been writing
                javascript and XBASIC over the last couple of years.

                Clearly there must be a fundamental bit of knowledge re: "object ID" and
                "object NAME" that I am missing.

                I always thought the "name" was optional, especially since everything else
                seems to work without them.

                I'll check in later... have to crash for a few hours.

                Danka!

                Comment


                  #9
                  Re: How to test the state of a &quot;window&quot; (is it open or closed)

                  I don't know for sure, but my guess is because the new V12 showContainerWindow() method and Window container type are an extension of the older "Open a Pop-up Ajax Window" action javascript routine. This routine can use one of five different sources of window content including a container. The builder for this action javascript routine and the Window container properties are almost identical. Since the window content for the "Open a Pop-up Ajax Window" action javascript routine may not necessarily be connected to a container with a unique id, a Window name placeholder was included to give the window a unique name.

                  However, I don't see why they could not at least default a Window-type container's window name property to the container id.

                  Comment


                    #10
                    Re: How to test the state of a &quot;window&quot; (is it open or closed)

                    Code:
                    function printObject(o)
                    {
                    	var out = '';
                    	var ctr = 0;
                    	
                    	for (var p in o)
                    	{
                    		out += p + ': ' + o[p] + '\n';
                    		ctr++;
                    		if (ctr > 24)
                    		{
                    			alert(out);
                    			out = '';
                    			ctr = 0;
                    		}
                    	}
                     
                     	if (ctr > 0)
                     	{
                     		alert(out);
                     	}
                    }
                    Works great. My simple initial version attempted to show too much in the alert and
                    I was going to just redirect the content to another panel with a DIV. However, yours
                    is a quick 'n dirty version that gets me all the properties quickly.

                    Danka!

                    Comment


                      #11
                      Re: How to test the state of a &quot;window&quot; (is it open or closed)

                      Originally posted by DaveF View Post
                      Allan - You need to assign a name to your window in order for {dialog.object}.getWindow() to work. Open the window properties for the WIN_MENU_MAIN control and enter "WIN_MENU_MAIN" in the Window name property. Then change your if statement to the following:

                      Code:
                      if (vl_menu_ref1.hidden)
                      {
                      	// Open the menu window if closed
                      	{dialog.object}.showContainerWindow(this,'WIN_MENU_MAIN');
                      }
                      else
                      {
                      	// Close the menu window if open
                      	{dialog.Object}.closeWindow('WIN_MENU_MAIN');
                      }
                      This worked great. Thanks much.

                      Comment

                      Working...
                      X