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 choose between the Xdialog events 'killfocus' and 'change'

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

  • How to choose between the Xdialog events 'killfocus' and 'change'

    I have decided in an XDialog not to handle all the fields at once after finishing input of all, but just field by field while entering data.

    I have an XDialog with some fields.
    Three are required fields let's call them: Name, Number and Street and they all are now trapped with their own killfocus event.
    Testing with some quick 'ENTER'-hits , I try to jump over the required fields.
    Sometimes I can jump out of the name and go to Number. At that moment I get a message from the killfocusevent for the required field(Name) but as Number also has lost its focus the Number_killfocus event is fired to.

    So must I change the 'killfocus' events into 'change' events? I do not want the user is able to skip a required field.
    Who is experienced with this and can advise?

    I can understand the working of the events by comparing to other eventnames.
    It seems to me that the 'change' event can be compared with 'can save' and 'killfocus' with 'on save' ? Is that right?

    How can the other events be compared?
    setfocus =
    cursor =
    changing =
    dblclick =
    selected

    BTW it is difficult to trap the focus events because while debugging. They 'setfocus' and 'killfocus' then every second.
    Is there a better trick than these? I just added this few lines while developing
    Code:
    SELECT
    	CASE "setfocus" $ a_dlg_button .or. "cursor" $ a_dlg_button .or. "change" $ a_dlg_button
    	a_dlg_button = ""
    	END

    Your suggestions and comments are welcome to.

    Ton
    Most things are simple but unfortunately only after the first time

  • #2
    Re: How to choose between the Xdialog events 'killfocus' and 'change'

    I have had an enormous amount of fun trying make this facet of the xdialog work for me. As I understand you need hand the occurrence of each event at the same time, even though you are only wanting the event on one eg:

    If a_dlg_button = "Surname_Killfocus" then

    do something

    elseif a_dlg_button = "Other_Killfocus"then do something else

    End if
    '--------------------
    If a_dlg_button = "Surname_Change" then

    do something

    elseif a_dlg_button = "Other_Change"then do something else

    End if

    I am still trying to work out how setfocus works. The help files could be a little better with this

    Comment


    • #3
      Re: How to choose between the Xdialog events 'killfocus' and 'change'

      Hi Mark

      Thanks for your quick reply.
      I know to construct them, but how and when to practice. That's the point.

      I have some other questions to as you've seen.

      BTW The setfocusevent fires as soon as you enter the field = field gets focus

      Ton
      Most things are simple but unfortunately only after the first time

      Comment


      • #4
        Re: How to choose between the Xdialog events 'killfocus' and 'change'

        Thanks for that - I thought it would allow me to setfocus to a particular field after an event fired. EG: Found an input error in a field and needed to fix it. I now realize my logic was wrong. I had this thought to be when the OK button is pushed but in reality it occurs at the kill_focus, changes or change.

        To overcome your issue (I think) I don't use event at all I use

        if a_dialog_button ="OK" .and. Var->Surname = "" then

        a_dialog_button = ""

        ui_msg_box("Field required","Surname must be filled in"

        end if

        This work great except I wanted it setfocus back to surname

        Comment


        • #5
          Re: How to choose between the Xdialog events 'killfocus' and 'change'

          ui_dlg_ctl_goto()
          Al Buchholz
          Bookwood Systems, LTD
          Weekly QReportBuilder Webinars Thursday 1 pm CST

          Occam's Razor - KISS
          Normalize till it hurts - De-normalize till it works.
          Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
          When we triage a problem it is much easier to read sample systems than to read a mind.
          "Make it as simple as possible, but not simpler."
          Albert Einstein

          http://www.iadn.com/images/media/iadn_member.png

          Comment


          • #6
            Re: How to choose between the Xdialog events 'killfocus' and 'change'

            If you find a good solution, post it so we will all know. (That's the main reason for this post - so I'll be notified.)

            I finally gave up on that method and simply test all the values when the user clicks the "OK" button. I found it to be far simpler and it works.

            I've also been known to do things like underline the field label for required fields or add an asterisk or put "(req'd)" after the field.

            Most users will figure out after a day or two of use that they must fill in required fields.

            Actually, most fields usually should be filled in so I'm more likely to put "(optional)" or just "(opt.)" next to the ones that aren't needed.

            BTW, I've also been known to put a default something like -999 in a numeric field that is required but 0 could be a valid value.

            Comment


            • #7
              Re: How to choose between the Xdialog events 'killfocus' and 'change'

              Thank you Al,

              When I went to help file on that it opened the world to me. That does the job just right.

              Now all i want is have an xdialog with a Field and a list view with no records. When I scan or type in the field it adds a found record to the LV. When you click save each list view row is saved.

              Anyone done that?

              Comment


              • #8
                Re: How to choose between the Xdialog events 'killfocus' and 'change'

                Hi Cal,

                Originally posted by CALocklin View Post
                If you find a good solution, post it so we will all know. (That's the main reason for this post - so I'll be notified.)

                I finally gave up on that method......
                I'm not sure I perceive the issue you and Ton have encountered.

                You can control the object(s) with Xdialog Text Pointer, UI_DLG_CTL_GOTO() which Al mentioned, as well as the XDialog Events to process when leaving the object in an XDialog.
                Regards,

                Ira J. Perlow
                Computer Systems Design


                CSDA A5 Products
                New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
                CSDA Barcode Functions

                CSDA Code Utility
                CSDA Screen Capture


                Comment


                • #9
                  Re: How to choose between the Xdialog events 'killfocus' and 'change'

                  I haven't tried it recently and those commands may work better than they did a few versions ago. As best I recall, there were just too many possible combinations of events to deal with that seemed to "interact" with each other causing all kinds of trouble. Maybe I should try it again now that I've used xdialog a tiny bit more and see if I can make it work.

                  Comment


                  • #10
                    Re: How to choose between the Xdialog events 'killfocus' and 'change'

                    Hi Cal,
                    Hope there come some experienced people with interesting comments.

                    As I stated I can break through a required field so killfocus may be to late in some ways to have a good control. That's the reason I am looking for someone more experienced who can 'confirm' or correct the way how I compared the events See #1. I want to know more of the behaviour of the events to make a right decision how to achieve my goal.


                    Hi Ira,
                    There are few examples in Learning Xdialog in the A5help, not explaining enough to me to be able to make my own variations.

                    In the A5help several textpointer functions are explained, but for me to poor and none of the examples don't work. They show just a detail and there is no totalview. look at e.g. <TEXT>.SET_CURSOR()
                    I have made an ealier post about text pointer issues but for me it's not clear. Did not get enough information to get me going.
                    That's why I now take this route using the events and try to get done what I need.

                    So I have to try and try untill the penny is dropped. If you have any answer on my questions of the post#1 please let me know.

                    Ton
                    Most things are simple but unfortunately only after the first time

                    Comment


                    • #11
                      Re: How to choose between the Xdialog events 'killfocus' and 'change'

                      Hi Ton,

                      I still don't understand the issue you should be having, but here is some sample code that shows you the events as well as does not allow leaving the "number" control unless you have some non-blank data in it.
                      Code:
                      '=========================================================================
                      ' Created by Computer Systems Design & Associates
                      ' Copyright 2010 Computer Systems Design & Associates, All Rights Reserved
                      ' http://www.csda1.com
                      '=========================================================================
                      'DESCRIPTION: Displays XDialog event information
                      
                      dim dlgtit as c
                      dlgtit="Test XDialog events"
                      
                      dim dlgbdy as c
                      dlgbdy=<<%dlg%
                      {startup=init}
                      {can_exit=close}
                      {region}
                      Name:|[name!nameevt_*];
                      Number:|[number!numberevt_*];
                      Street:|[street!street_*];
                      {endregion};
                      Event List;
                      {text=40,20eventlist1};
                      {region}<OK> <Cancel> <Clear Events!clearevents>{endregion}
                      %dlg%
                      
                      dim dlgevt as c
                      dlgevt=<<%code%
                      IF (UT(a_dlg_button)=="CLOSE").or.(UT(a_dlg_button)=="CANCEL")
                          ui_modeless_dlg_close(dlgtit)
                      ELSE IF (UT(a_dlg_button)=="OK")
                          ui_modeless_dlg_close(dlgtit)
                      ELSE IF (UT(a_dlg_button)=="CLEAREVENTS")
                          eventlist=""
                      ELSE IF (UT(a_dlg_button)=="INIT")
                          ' Initialization code here
                          eventlist=""
                          ' Only show most recent 20 lines of events
                          eventlist1=word(eventlist,max(1,line_count(eventlist)-20),crlf(),20)
                          ' Show all events
                      '    eventlist1=eventlist
                      ELSE
                          ' Add event for those we want to track to event list at top in reverse order
                          eventlist=eventlist+a_dlg_button+Crlf()
                          ' Only show most recent 20 lines of events
                          eventlist1=word(eventlist,max(1,line_count(eventlist)-20),crlf(),20)
                          ' Show all events
                      '    eventlist1=eventlist
                      
                          ' Process events    
                          IF left(UT(a_dlg_button),8)=="NAMEEVT_"
                              evt=substr(a_dlg_button,9)
                              ' Do what you need here to process event
                          ELSE IF left(UT(a_dlg_button),10)=="NUMBEREVT_"
                              evt=substr(a_dlg_button,11)
                              ' Do what you need here to process event
                      
                              ' This code will move focus back to field if trying to leave and field is blank
                              IF ut(evt)=="KILLFOCUS"
                                  IF trim(number)==""
                                      ui_dlg_ctl_goto(dlgtit,"number")
                                  END IF
                              END if
                                  
                          ELSE IF left(UT(a_dlg_button),10)=="STREETEVT_"
                              evt=substr(a_dlg_button,11)
                              ' Do what you need here to process event
                      
                          END IF
                      END IF
                      
                      a_dlg_button=""
                      
                      END
                      %code%
                      
                      dim eventlist as c
                      dim eventlist1 as c
                      dim evt as c
                      
                      ' Display as modeless, as we can look at it and modify code while open
                      ui_modeless_dlg_box(dlgtit,dlgbdy,dlgevt)
                      Regards,

                      Ira J. Perlow
                      Computer Systems Design


                      CSDA A5 Products
                      New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
                      CSDA Barcode Functions

                      CSDA Code Utility
                      CSDA Screen Capture


                      Comment


                      • #12
                        Re: How to choose between the Xdialog events 'killfocus' and 'change'

                        Hi Ira,

                        This is really great. Thank your very much for what you've created. It shows very clear which and when events fire.

                        I have seen that while changing or adding the 'changing' event fires and also following by the change event. Each after every character.
                        Question how to choose between the events is solved by new insight.

                        I must have so more time to investigate. Special how to implement required fields in my own function.

                        It is almost impossible to debug an XDialog because then the setfocus and killfocus events fires continuous in an endless loop. Therefore I can recommend this as a valuable example for anyone who wants to know more about eventhandling in XDialog because you can see interactive what's going on.

                        Ton
                        Most things are simple but unfortunately only after the first time

                        Comment


                        • #13
                          Re: How to choose between the Xdialog events 'killfocus' and 'change'

                          Originally posted by csda1 View Post
                          I still don't understand the issue you should be having, but here is some sample code that shows you the events as well as does not allow leaving the "number" control unless you have some non-blank data in it. ...
                          Here's your code modified the way I would do it to require both the number AND street fields to be filled. See the two new "ELSEIF" statements.

                          Just try to tab through leaving all fields blank. Since the two fields being checked are sequential it puts you in an endless loop.

                          Of course, I'd usually provide a message telling the user what was wrong. SO, if you really want to have fun, unrem the ui_msg_box() line and run it. Be prepared to use the 3-finger salute to exit.

                          This is why I decided to give up and just check for all required fields (or allowed values, etc.) when the user clicks the OK button. Usually if I'm checking for one field, I'm checking for others as well and providing messages to tell the user what needs to be corrected. You can check one field "on the fly" but may have problems if more than one is to be checked that way. Even if they aren't sequential, the user may use the mouse to click from one to the other and cause the same problem.

                          There's probably some amount of additional variable checking that could be done to get around this but is it worthwhile? And how bad will it get if you want to check, say, 10 different values?
                          Code:
                          '=========================================================================
                          ' Created by Computer Systems Design & Associates
                          ' Copyright 2010 Computer Systems Design & Associates, All Rights Reserved
                          ' http://www.csda1.com
                          '=========================================================================
                          'DESCRIPTION: Displays XDialog event information
                          
                          'Modified by Cal to demonstrate an issue.
                          
                          dim dlgtit as c
                          dlgtit="Test XDialog events"
                          
                          dim dlgbdy as c
                          dlgbdy=<<%dlg%
                          {startup=init}
                          {can_exit=close}
                          {region}
                          Name:|[name!nameevt_*];
                          Number:|[number!numberevt_*];
                          Street:|[street!street_*];
                          {endregion};
                          Event List;
                          {text=40,20eventlist1};
                          {region}<OK> <Cancel> <Clear Events!clearevents>{endregion}
                          %dlg%
                          
                          dim dlgevt as c
                          dlgevt=<<%code%
                          IF (UT(a_dlg_button)=="CLOSE").or.(UT(a_dlg_button)=="CANCEL")
                              ui_modeless_dlg_close(dlgtit)
                          ELSE IF (UT(a_dlg_button)=="OK")
                              ui_modeless_dlg_close(dlgtit)
                          ELSE IF (UT(a_dlg_button)=="CLEAREVENTS")
                              eventlist=""
                          ELSE IF (UT(a_dlg_button)=="INIT")
                              ' Initialization code here
                              eventlist=""
                              ' Only show most recent 20 lines of events
                              eventlist1=word(eventlist,max(1,line_count(eventlist)-20),crlf(),20)
                              ' Show all events
                          '    eventlist1=eventlist
                          ELSEIF left( a_dlg_button, 10 ) = "numberevt_"
                              IF a_dlg_button = "numberevt_killfocus"
                                  IF number = ""
                                      ui_dlg_ctl_goto(dlgtit,"number")
                                  END IF
                              END IF
                          ELSEIF left( a_dlg_button, 7 ) = "street_"
                              IF a_dlg_button = "street_killfocus"
                                  IF street = ""
                                      ui_dlg_ctl_goto(dlgtit,"street")
                                     'If you are willing to Ctrl-Alt-Del to get out of it, unrem the following:
                                     'ui_msg_box( "REQUIRED", "Street name is required." )
                                  END IF
                              END IF
                          ELSE
                              ' Add event for those we want to track to event list at top in reverse order
                              eventlist=eventlist+a_dlg_button+Crlf()
                              ' Only show most recent 20 lines of events
                              eventlist1=word(eventlist,max(1,line_count(eventlist)-20),crlf(),20)
                              ' Show all events
                          '    eventlist1=eventlist
                          
                              ' Process events    
                              IF left(UT(a_dlg_button),8)=="NAMEEVT_"
                                  evt=substr(a_dlg_button,9)
                                  ' Do what you need here to process event
                              ELSE IF left(UT(a_dlg_button),10)=="NUMBEREVT_"
                                  evt=substr(a_dlg_button,11)
                                  ' Do what you need here to process event
                          
                                  ' This code will move focus back to field if trying to leave and field is blank
                                  IF ut(evt)=="KILLFOCUS"
                                      IF trim(number)==""
                                          ui_dlg_ctl_goto(dlgtit,"number")
                                      END IF
                                  END if
                                      
                              ELSE IF left(UT(a_dlg_button),10)=="STREETEVT_"
                                  evt=substr(a_dlg_button,11)
                                  ' Do what you need here to process event
                          
                              END IF
                          END IF
                          
                          a_dlg_button=""
                          
                          END
                          %code%
                          
                          dim eventlist as c
                          dim eventlist1 as c
                          dim evt as c
                          
                          ' Display as modeless, as we can look at it and modify code while open
                          ui_modeless_dlg_box(dlgtit,dlgbdy,dlgevt)

                          Comment


                          • #14
                            Re: How to choose between the Xdialog events 'killfocus' and 'change'

                            Ton,

                            Rather than trying to control the sequence of prompts (i.e. "avoiding the skipping", etc.), I often make sure that certain prompts have been answered by controlling the OK button ... sort of like what Mark alluded to.

                            But using a logical variable of bOK to control whether the OK button is enabled, the user cannot finish the xdialog without all necessary prompts being answered. In the sample below, if "Yes" is selected for the radio button and no name has been selected, the OK button is disabled.

                            This requires recalculating bOK for every necessary prompt to see if the necessary input has been satisfied.

                            Steve

                            Code:
                            DIM SHARED bInterm as L
                            DIM SHARED bOK as L
                            DIM SHARED cName as C
                            'auto_list_cName = table.external_record_content_get("ee_pos","Lfname","Lfname","")
                            auto_list_cName = <<%aaa%
                            Tom
                            Dick
                            Harry
                            %aaa%
                            temp_count = w_count(auto_list_cName,crlf())
                            DELETE a_cName
                            DIM a_cName[temp_count] as c
                            a_cName.initialize(auto_list_cName)
                            DIM SHARED varC_result as C
                            cInterm = "No"
                            bInterm = .F.
                            bOK = .T.
                            ok_button_label = "&OK"
                            cancel_button_label = "&Cancel"
                            varC_result = ui_dlg_box("Leave Input Forms",<<%dlg%
                            {region}
                            {region}New Intermittent Leaves?:{endregion}
                            {region}|(cInterm:Yes!cInterm_);
                            |(cInterm:No!cInterm_);{endregion};
                            ;
                            {endregion};
                            {condition=bInterm}
                            {line=1,0};
                            {region}
                            Employee:| [.45,5cName^#a_cName!cName_];
                            {endregion};
                            {condition=.t.}
                            {line=1,0};
                            {region}
                            <*12=ok_button_label!OK?bOK> <12=cancel_button_label!CANCEL>
                            {endregion};
                            %dlg%,<<%code%
                            if left(a_dlg_button,8) = "cInterm_" then 
                            	bInterm = (cInterm = "Yes")
                            	bOK = (.NOT.bInterm .OR. cName <> "")
                            	a_dlg_button = ""
                            end if
                            if left(a_dlg_button,6) = "cName_" then 
                            	bOK = (.NOT.bInterm .OR. cName <> "")
                            	a_dlg_button = ""
                            end if
                            %code%)
                            
                            if varC_result <> "OK"
                            	END
                            end if

                            Comment


                            • #15
                              Re: How to choose between the Xdialog events 'killfocus' and 'change'

                              I agree with Steve and have done the same thing - except that I'd add "in some cases". As with most things in programming, there always seem to be multiple ways to accomplish the same thing. The trick is to pick the one that works best for the current situation.

                              Sometimes it's very obvious what needs to be completed to get the OK button to activate. This is often true with xdialogs that only have a few fields/choices.

                              However, take a look at the attached screenshot. That xdialog has 28 user editable fields and most of them have some type of requirement that needs to be tested. One of the most complicated is the "riders" area. If the "Riders" box is not checked, then the other rider fields are disabled - that's pretty obvious to the user. But, if the "Riders" box is checked, then either Stock Riders or Agent Riders or both must have an entry and if either of those is filled in then there must be a corresponding quantity - there is also an upper limit on the quantity which is based on the order quantity at the top. When things get this complicated it can be very hard for the user to determine what's wrong when the OK button is still disabled. In cases like this it's better to check when they click the OK button and provide a warning message to tell them what's wrong. Most of the time the warning message will only tell them about the first error found - which means new users may have to make a few tries before they are done but they usually learn pretty quickly. (I tried one where I provided all the errors in sequence but each warning was a separate short message because I've found that people won't read long messages. Clicking off multiple messages just made the users angry. They preferred to deal with them one at a time.)

                              FWIW: Yes, that xdialog probably has more fields on it than any other I've created. It may not be the most complicated "behind the scenes" but it's definitely the busiest on the screen.

                              Later: I just realized the attached screenshot was from the "edit" version which doesn't allow all fields to be changed. However, that still leaves 18 fields that can be edited and my point remains the same.
                              Last edited by CALocklin; 01-12-2010, 11:39 AM.

                              Comment

                              Working...
                              X