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

OnKey Event not firing ?

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

    OnKey Event not firing ?

    Hello,

    Next difficulty i ran into is the following:

    i have a form setup (see attached zip) where the user inputs a number, pushes the search button and the record is displayed.

    I want to implement that when the user is on the searchfield, types in the number, and pushes the ENTER key the searchbutton push event is called....

    This looked the correct way to me:

    Code:
    if parentform.active()="searchfield" 	
    	if a_user.key.value ="{ENTER}".and. a_user.key.event = "down"
    		a_user.key.handled = .T.
    		searchbutton.push()
    	end if
    
    end if
    this piece of code wash put in the OnKey event of the form but does not work. It is not that the searchbutton.push() dont work, when i put a ui_msg_box just in front nothing happens so the script doesnt get there...

    I read in the forum that one can do a workaround by adding a user control to the form and put it in the onkey event of this control, but that did not work either.

    It works now by putting the code in OnKey of the FORM and putting a user control with no events changed on the FORM.

    BUT when i implement this in my app is doet NOT work ?

    Is there something i am missing or is this a bug ?

    thanx for your help,

    Olivier

    #2
    Re: OnKey Event not firing ?

    Your script and form work for me. I started your "searchform" and then entered "123" in the search field, pressed {enter}, and got an error message that "123 not found!", which I assume is correct. What doesn't work for you?

    Comment


      #3
      Re: OnKey Event not firing ?

      Originally posted by Peter.Wayne View Post
      Your script and form work for me. I started your "searchform" and then entered "123" in the search field, pressed {enter}, and got an error message that "123 not found!", which I assume is correct. What doesn't work for you?
      Correct, the script works this way. If you remove the user control however it does not work anymore. There is no code attached to the user control and still if i remove it it stops working.
      Problem is if i implement this script exactly into my main app it does not work, even with the user control on the form ?
      Dont know if i do something wrong with the scripting ?

      Maybe i should hav posted the script without the user control on it, that would make it more clear. Sorry

      Comment


        #4
        Re: OnKey Event not firing ?

        I took the user control out and it still works for me. The only change I made was to change
        if parentform.active() = "searchfield"
        to
        if this.active()
        since parentform really isn't appropriate for an event on the form. Nevertheless, even though it's not appropriate, I think that it usually works; however, if the form is launched as a subform from another form, it's more than possible that parentform refers to the original form, and not to what you think it refers to. That would mean that Xbasic can't locate "searchfield" because it's looking in the wrong form. Try making the change to this.active() and see if your problems disappear.

        Comment


          #5
          Re: OnKey Event not firing ?

          Originally posted by Peter.Wayne View Post
          I took the user control out and it still works for me. The only change I made was to change
          if parentform.active() = "searchfield"
          to
          if this.active()
          since parentform really isn't appropriate for an event on the form. Nevertheless, even though it's not appropriate, I think that it usually works; however, if the form is launched as a subform from another form, it's more than possible that parentform refers to the original form, and not to what you think it refers to. That would mean that Xbasic can't locate "searchfield" because it's looking in the wrong form. Try making the change to this.active() and see if your problems disappear.
          Hi Peter, the form runs indeed as a subform. I tried your suggestion but that does not change anything.

          I now removed all code from the onkey event from the form and just placed:

          Code:
          ui_msg_box("","key pressed")
          Then when i run the form by itself (instead of running the mainform that calls it) it should give me a messagebox everytime i hit a key but it does nothing.... When ran as a subform from the mainform: same thing...

          Is there anything that can prevent a form from fireying the onkey event ?

          btw, i run v9 on vista... but that is probably not the problem?

          Comment


            #6
            Re: OnKey Event not firing ?

            Hate to ask, but are you running the latest patch of v9, before we get any further?

            Comment


              #7
              Re: OnKey Event not firing ?

              Originally posted by Peter.Wayne View Post
              Hate to ask, but are you running the latest patch of v9, before we get any further?
              1600_3196 build, latest version....

              Comment


                #8
                Re: OnKey Event not firing ?

                Also, since it works for me, let's make sure we're both working with exactly the same database, not just the same form. I'm attaching my copy of your form.

                Comment


                  #9
                  Re: OnKey Event not firing ?

                  Originally posted by Peter.Wayne View Post
                  Also, since it works for me, let's make sure we're both working with exactly the same database, not just the same form. I'm attaching my copy of your form.
                  Peter, the version you sent me works here... when i try to implement this exactly in my app everything works fine as long as there is no subform on the form.
                  So when i put the searchfield and button on the form the onkey event works but when i insert a subform on the form the onkey event stops firing...

                  Should be a problem with my setup i think?

                  Comment


                    #10
                    Re: OnKey Event not firing ?

                    You have a subform on that form -- you've just hidden it (I don't know why). So it's not that there's no subform on what I sent you.
                    Why don't you post enough of your application to illustrate the bug. Start with what I sent you and add enough forms to make it happen, and describe what you're doing. Otherwise it's just an exercise in mutual frustration: you're not getting any help and no one can duplicate your issue.

                    Comment


                      #11
                      Re: OnKey Event not firing ?

                      The part in red is redundant.
                      Code:
                      [COLOR="Red"][B]if parentform.active()="searchfield" 	[/B][/COLOR]
                      	if a_user.key.value ="{ENTER}".and. a_user.key.event = "down"
                      		a_user.key.handled = .T.
                      		searchbutton.push()
                      	end if
                      [COLOR="Red"][B]end if[/B][/COLOR]
                      Not sure why a subform will stop it from working, but it won't hurt to modify your script to:
                      Code:
                      	if a_user.key.value ="{ENTER}".and. a_user.key.event = "down"
                      		a_user.key.handled = .T.
                      		searchform:searchbutton.push()
                      Later:
                      Do you have the same field (searchnumber) in the subform?
                      I bet you do.
                      Last edited by G Gabriel; 07-22-2008, 01:46 PM.

                      Comment


                        #12
                        Re: OnKey Event not firing ?

                        Later:
                        Do you have the same field (searchnumber) in the subform?
                        I bet you do.

                        Comment


                          #13
                          Re: OnKey Event not firing ?

                          Peter

                          In Olivier's origina zip file - goto the form "searchsubform1". Open it in design mode and left click - in the onKey event he has some code. Delete the entire onkey event on that form.

                          Now open the searchform, enter a number into the searchfield and then press enter.

                          What happens?

                          I don't have access to V9 here, so I am using V8 (there is no unique code in the xbasic so V8 should work)

                          When I remove the code from the onKey event in the subform (leave nothing in the onkey event) the onkey event in the searchform does not work - enter just acts like a tab key and goes to the next field (or button) in tab order which is the search button.

                          I didn't know subforms acted that way. I may be missing something also.

                          Tom Baker

                          Comment


                            #14
                            Re: OnKey Event not firing ?

                            Works with or without the OnKey event of the subform.

                            Comment


                              #15
                              Re: OnKey Event not firing ?

                              See response to your other thread.

                              Comment

                              Working...
                              X