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

Xdialog button events fire too many times

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

    Xdialog button events fire too many times

    I would like to know if this is a bug or a feature, as it impacts development decisions for me. Any time I select any button, an event fires for all the buttons.

    Run this xdialog below and watch the Trace window. Any time you select a button control, the "_changing" event fires for ALL the buttons, not just the one selected. And then a "_" (blank) event fires for the selected button. Perhaps it was never contemplated that someone would want to see all the events for a button control, but I do. Or maybe it's a known feature that I just stumbled upon. I'm using v10.5 build 3432-3608.

    Please confirm if you see the same results, thanks.

    Code:
    'Buttons seem to fire events TWICE, including an 'unnamed' event
    dim nTotal as n = 0
    dim cTotal as c = "0"
    
    ui_dlg_box("Buttons Fire Twice?",<<%dlg%
    {lf=2};
    {wrap=80}
    When you TAB over to any of these buttons and press ENTER, events fire for ALL the buttons.;
    {lf=1};
    Is this a BUG or is it EXPECTED BEHAVIOR?
    {lf=3};
    {region}
    	Click here to end the demo: | (EndDemo!EndDemo clicked);
    	Total events that fired: | {text=10cTotal}
    {endregion}
    {lf=3};
    {justify=center,center}
    <25,2Button 1 - B1!B1_*> <35,2Any Text Here - B2!B2_*> <25,2And One More - B3!B3_*>;
    <35,2Should be One Event Here - B4!B4>
    %dlg%,<<%code%
    nTotal = nTotal + 1					'See how many times we loop through there
    cTotal = alltrim(str(nTotal))
    trace.writeln("E:"+a_dlg_button+", Tot:"+nTotal)	'Show the event
    if left(a_dlg_button,1) = "B"
    	'Trap all those events here, then clear it so it loops continuously
    	if right(a_dlg_button,1) = "_"
    		trace.writeln("This event fired: " + a_dlg_button)
    	end if
    	a_dlg_button = ""
    end if
    %code%)
    Last edited by EJR; 10-18-2010, 01:38 PM. Reason: typo
    There are three kinds of people in the world: those who can count, and those who can't.

    #2
    Re: Xdialog button events fire too many times

    No bugs.
    Add this one to the pamphlet: "Mysteries of the xdlg"!
    You got 2, Ira had one but my all time favorite is one by Mike Wilson.

    The events are tied to buttons. Contrary to any other controls on the xdlg, once loaded, the buttons (all of them) are in a state of "changing", hence they all fire since you have an event attached to each of them and since you are not specific as to which event.

    Comment


      #3
      Re: Xdialog button events fire too many times

      This is rather strange but that's also an incorrect usage of the event syntax.

      I realize that you were probably trying to find out if there were other events for buttons but the use of an asterisk in a button event isn't supported because buttons only have one event. Since it isn't supported, the code isn't designed to handle it and that's why you are getting strange results.

      If you remove the "*" from your event names you will get only one event triggered each time you push a button.

      Also note that you were able to trap an "event" that ended with the underscore. This is probably because there is no event defined to replace the "*" when used in button events. In fact, buttons don't even need a specific event definition because the button text itself will be the event name.

      The <25,2Button 1 - B1!B1_*> button in your script could be simply:
      <25,2Button 1 - B1>
      and the event name when pushed would be "Button 1 - B1".
      However, I often add a specific event name to replace "complex" button text just to make life easier for me. In this case I'd probably use:
      <25,2Button 1 - B1!btn1>
      This would make typing easier AND I could change the button text without the need to change the event handling code - no matter what the text is, the event name remains "btn1". (I find that multi-word button text often gets "finessed" during development.) However, for a simple OK or Cancel button I don't bother adding an event name - typing <15OK!OK> just doesn't make sense to me.

      Run the following code and you will note (A) button events only fire when the button is clicked and (B) the "*" in the event (sv_*) for the new field object will ALWAYS be replaced by some additional event name such as Changing, Changed, KillFocus, etc. The result is NEVER simply "sv_".

      Code:
      Button events don't fire twice anymore.
      DIM nTotal as N = 0
      DIM cTotal as C = "0"
      ui_dlg_box( "Buttons Fire Twice?", <<%dlg%
      {lf=2};
      {wrap=80}
      When you TAB over to any of these buttons and press ENTER, events fire for ALL the buttons.;
      {lf=1};
      Is this a BUG or is it EXPECTED BEHAVIOR?
      {lf=3};
      {region}
          Click here to end the demo: | (EndDemo!EndDemo clicked);
          Total events that fired: | {text=10cTotal};
          Field: [.20,1Some_Val!sv_*];
      {endregion}
      {lf=3};
      {justify=center,center}
      <25,2Button 1 - B1!B1_> <35,2Any Text Here - B2!B2_> <25,2And One More - B3!B3_>;
      <35,2Should be One Event Here - B4!B4>
      %dlg%,<<%code%
      nTotal = nTotal + 1                    'See how many times we loop through there
      cTotal = alltrim( str( nTotal ) )
      trace.writeln( "E:" + a_dlg_button + ", Tot:" + nTotal )    'Show the event
      IF left( a_dlg_button, 1 ) = "B"
          'Trap all those events here, then clear it so it loops continuously
          IF right( a_dlg_button, 1 ) = "_"
              trace.writeln( "This event fired: " + a_dlg_button )
          END IF
          a_dlg_button = ""
      ELSEIF left( a_dlg_button, 3 ) = "sv_"
          trace.writeln( "This event fired: " + a_dlg_button )
          a_dlg_button = ""
      END IF
      %code% )

      Comment


        #4
        Re: Xdialog button events fire too many times

        Thanks, Cal, but... I copied your code and if you TAB or SHIFT-TAB to a button and press ENTER, the button event fires twice.

        You are correct that I was playing with things to see how far I could go since I wanted to understand AlphaFive better (I used to program in C and assembly and that would get me into LOTS of trouble!). So I have no fear trying things I shouldn't do. And I'll have lots more fun when I start creating DLLS with FASM to speed up some text-manipulation tasks in A5.

        I think I agree with you and G. that this is probably not a bug that needs to be addressed, as it is undocumented, so "unpredictable results" are fair game. But there is one part of this that I'm still thinking about, though it also may not be a bug.

        If you click on a button and query with ui_dlg_clt_current, the control reported as "current" is the one where the cursor was immediately before you clicked. But if you TAB to the button and press ENTER (or click), you are told that the button you are selecting is the current control. (And sometimes the control name is returned with a CR/LF + TAB in front.) Rereading what I just wrote here, this is probably a good design - clicking a control probably shouldn't change focus, whereas tabbing should. (But adding CR/LF/TAB in front??)

        Again, thanks for spending time on this. I'm fine with the current behavior, but wanted to know if this was considered a bug (in which case the behavior would change) or not (in which case I can depend on what I now know is going on).
        Last edited by EJR; 10-19-2010, 04:45 PM. Reason: typos
        There are three kinds of people in the world: those who can count, and those who can't.

        Comment


          #5
          Re: Xdialog button events fire too many times

          In other applications.. javascript for instance, buttons have several events. In alpha, more specifically in xdlg, you could only press the button and that's that.

          I don't know where you dream these things up (and I mean that as a complement) because you unearth these intricacies about the xdlg with these schemes. Adding these events to the buttons with virtually identical events' names unearthed the fact that in alpha when an xdlg is loaded the button is in a "changing" state. Well, yeh.. it is.. it is waiting for you to do something..or nothing. One might philosophize the merit behind that, and whether it should be in a changing state at all, but I wouldn't call it a bug. If you were to follow "proper" coding, i.e. why would you want to have names in common for different events in different buttons? and why would you want to trap a button event? In alpha, in xdlg that is? If you just follow the norms and give the button event a distinct name you wouldn't run into this. I am glad you did though.

          Originally posted by EJR View Post
          But there is one part of this that I'm still thinking about, though it also may not be a bug.

          If you click on a button and query with ui_dlg_clt_current, the control reported as "current" is the one where the cursor was immediately before you clicked. But if you TAB to the button and press ENTER (or click), you are told that the button you are selecting is the current control.
          Once again, this is one of those subtilties. Someone asked a similar question recently in a different thread and I explained the difference.

          Comment


            #6
            Re: Xdialog button events fire too many times

            Thanks for the compliment. I "dream these things up" because I want to know how things work and I like to just jump in and then, if I'm hopelessly lost, I'll search for the answer. I'm learning fast because I keep pushing myself, and it's great to have people such as yourself and the others who are regulars on this forum. And if I can help somebody else skip over the problems I've run into, I feel better.

            And here's the clincher that I think is good for all A5 users: almost invariably, when I think I've found a pesky little bug, it turns out I didn't understand the big picture, and my design or implementation was at fault. And I've seen this happen with many others, too. And even though I have found a couple of real bugs that have been/are being fixed, this is helping me feel more and more comfortable with A5.
            Last edited by EJR; 10-19-2010, 08:03 PM. Reason: typos
            There are three kinds of people in the world: those who can count, and those who can't.

            Comment

            Working...
            X