Which event is in use

Post

Posted
Rating:
#1 (In Topic #929)
Enthusiast
gambafeliz is in the usergroup ‘Enthusiast’
 I have a FMain and other Form1 into the panel what is your parent, a GridView into the Form1 and I do the following:

1. I scroll the gridview with the mouse wheel and we can see that the rows move.
2. I have a KeyPress Event on the Form1 to detect that you press ESC. But when I scroll, and then press ESC I don't detect the ESC press on the Form1.

Where is the event at that time? Can someone tell me what I can do to find out?

For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)
Online now: No Back to the top

Post

Posted
Rating:
#2
Enthusiast
gambafeliz is in the usergroup ‘Enthusiast’
 I have observed that FMain receives the ESC but how do I return ESC to Form1 without the user noticing.

Can I forward ESC from FMain to Form1 somehow? any other good solution?

For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Guru
cogier is in the usergroup ‘Guru’
Can you post an example program, so we can see what you mean.
Online now: No Back to the top

Post

Posted
Rating:
#4
Guru
BruceSteers is in the usergroup ‘Guru’
If you are in the FMain Form_KeyPress() event handler then all the Key.class info is live so you could just call the Form_KeyPress() event in Form1.
(providing they both use Form_Keypress())
In FMain you should be able to do this..

Code (gambas)

  1. Public Sub Form_KeyPress()
  2.  
  3.   Form1.Form_KeyPress()
  4.  
  5.  

Public methods with an underscore are hidden from other classes in the IDE auto-complete but they can still be used.
Online now: No Back to the top

Post

Posted
Rating:
#5
Enthusiast
gambafeliz is in the usergroup ‘Enthusiast’
 It seems that your proposal works.

But I return the focus to Form1 from FMain's KeyPress and then do…

with Desktop.SendKeys in FMain but I don't know how to send ESCAPE, any idea about it. Thanks.

For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)
Online now: No Back to the top

Post

Posted
Rating:
#6
Enthusiast
gambafeliz is in the usergroup ‘Enthusiast’
Hey BruceS your proposal is amazing :)

For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)
Online now: No Back to the top

Post

Posted
Rating:
#7
Guru
BruceSteers is in the usergroup ‘Guru’

gambafeliz said

It seems that your proposal works.

But I return the focus to Form1 from FMain's KeyPress and then do…

with Desktop.SendKeys in FMain but I don't know how to send ESCAPE, any idea about it. Thanks.

SendKeys should not be needed Because the Key class is valid.
Ie.
in the FMain Form_KeyPress() event if Key.Code = Key.Esc and you call the Fom1.Form_KeyPress() method then Key.Code will be the same as you are still inside the FMain KeyPress event.

gambafeliz said

Hey BruceS your proposal is amazing :)

cool , glad it works.
Another option is to not let Form1 loose focus.
pressing a button on another form looses the form1 focus so it no longer gets the keypress event , so you could call Form1.SetFocus after any button click on the other form that steals the focus to put it back.
Online now: No Back to the top

Post

Posted
Rating:
#8
Enthusiast
gambafeliz is in the usergroup ‘Enthusiast’
 But prevent me from stealing the Esc keystroke? give me an example

I tell you because I press Esc but at that moment I don't know what receives it, let's say the parent and not Form1 as I expected.

For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)
Online now: No Back to the top

Post

Posted
Rating:
#9
Guru
BruceSteers is in the usergroup ‘Guru’

gambafeliz said

But prevent me from stealing the Esc keystroke? give me an example

I tell you because I press Esc but at that moment I don't know what receives it, let's say the parent and not Form1 as I expected.

It's about what has focus.

If you press a button or any other control that is on FMain then that control has the focus and so does FMain.
So a keypress then goes to FMain Keypress event.

If you press a control on Form1 then Form1 has focus.

So if you have a button on FMain called, btnDoSomething it should do this..

Code (gambas)

  1.  
  2. Public Sub btnDoSomething_Click()
  3.  
  4.   ' run some code
  5.  
  6.  
  7.   Form1.SetFocus ' return focus to Form1 when finished
  8.  
  9.  

Or if you need to monitor the escape key during the function reset the focus first

Code (gambas)

  1.  
  2. Public Sub btnDoSomething_Click()
  3.  
  4.   Form1.SetFocus ' return focus to Form1 before starting
  5.  
  6.  
  7.   ' run some code
  8.  
  9.  


Maybe you have it working okay, this was just an alternative suggestion.
Online now: No Back to the top

Post

Posted
Rating:
#10
Enthusiast
gambafeliz is in the usergroup ‘Enthusiast’
 Hello

First thank you all for your help. Thanks.

I'll tell you in summary:

The Form1.Form_KeyPress() proposal works but something mysterious is going on that I can't figure out. I tell you but without providing code.

I load data into a GridView and when I click on a row it reloads this GridView with another query. And when I hit ESC I go back to the previous query and load it into the same GridView. Since I remember these queries, I load them into a String array and remove or add queries based on Click or Esc.

The problem is that when I use Form1.Form_KeyPress() in FMain, it works but when it repeats the KeyPress() code in Form1, although I follow it and see that it does everything right, the GridView freezes with the data it had, and it doesn't I don't know where I don't know what happens with the data I upload.

My solution: When Esc is lost and stolen by FMain instead of using Form1.Form_KeyPress(), I use Form1.SetFocus() but this has another problem and that is that the user's Esc key is lost, and I have no choice but to to make the user think that he did not press well and when he repeats Esc then everything is fine, but this for me is a rookie mistake.

What is your opinion? Thanks.

For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)
Online now: No Back to the top
1 guest and 0 members have just viewed this.