Page 1 of 1

OnEnter, ActiveWindow, SendEvent....

Posted: Thu Jun 09, 2011 4:29 pm
by l3whmg
Hi guys.

Perhaps :roll: I find solution to use OnEnter with Textbox, Button and...

Before applying the solution, I want present to you my pov because I must move the OnEnter method (not ::bOnEnter) into every control (window, textbox, button, etc.) who want use this.
This action is due, because someone widget operates in a different way to intercept the Enter key (to see take a look to every ProcessEnter method).
I tried to write a generic method and then overwrite the method for each control, but the operation has given mixed results: I don't know, sorry :oops:

Second I find how to force/send event; take a look at LQTBASIC:SendEvent()
Third, I find solution to know what is the QT active Window: take a look inside LQTBASIC:GetActQtWin()

Also take a look to:
A) LQTBASIC:OnInit used to connect the event Show
B) LQTBASIC:OnInteractiveClose and LQTBASIC:OnRelease used to connect the (same) event Close, but read comment inside Main Function
C) small difference inside some methods
D) last but not least. I prefer this syntax

Code: Select all

CLASS CHECKBUTTON FROM APPLICATION,CONTROL,BASIC
then this chain

Code: Select all

CLASS CHECKBUTTON FROM CONTROL
CLASS CONTROL FROM BASIC
CLASS BASIC FROM APPLICATION
But it's my humble opinion. Someone can tell me what is better or problems :?:

I have attached an example: it's my HMG4 fork to do test. HMG4 lib it's not required.
To compile the test program, you must change .hbc and .hbp files in according with your installation.

When you run the pogram:
On the first textbox write something (if you want) and press return. The same on second textbox.
On the button you can: click or press return
Somewhere on the window (not over controls) try to click

Write me your impressions and opinions :mrgreen:

Best regards

Re: OnEnter, ActiveWindow, SendEvent....

Posted: Mon Jul 04, 2011 10:52 am
by pctoledo
This solution will not added in HMG4?

Re: OnEnter, ActiveWindow, SendEvent....

Posted: Mon Jul 04, 2011 11:29 am
by l3whmg
Hi Pctoledo.
In this moment no. I want include it, but I must understand the impact of this event handling with HMG4. I will try today.
On the other hand, I have added something in this two days.

Best regards

Re: OnEnter, ActiveWindow, SendEvent....

Posted: Mon Jul 04, 2011 2:33 pm
by pctoledo
Ok Luigi.. I'll wait ... thanks!

Re: OnEnter, ActiveWindow, SendEvent....

Posted: Mon Jul 04, 2011 5:18 pm
by mrduck
l3whmg wrote: D) last but not least. I prefer this syntax

Code: Select all

CLASS CHECKBUTTON FROM APPLICATION,CONTROL,BASIC
then this chain

Code: Select all

CLASS CHECKBUTTON FROM CONTROL
CLASS CONTROL FROM BASIC
CLASS BASIC FROM APPLICATION
I can't think about possible problems now, but I'm against the multiple inheritance if not strictly strictly necessary.

Re: OnEnter, ActiveWindow, SendEvent....

Posted: Mon Jul 04, 2011 6:06 pm
by concentra
mrduck wrote:I'm against the multiple inheritance if not strictly strictly necessary.
Me too.

Re: OnEnter, ActiveWindow, SendEvent....

Posted: Mon Jul 04, 2011 7:05 pm
by l3whmg
Hi guys,
please do not shoot me too :lol:
Cheers

Re: OnEnter, ActiveWindow, SendEvent....

Posted: Mon Jul 04, 2011 8:08 pm
by l3whmg
Hi friends.
I've done a commit. This is changelog
2011-07-04 22:00 UTC+0100 Luigi Ferraris ( <luigi at l3w.it> )
! samples/label/demo_1.prg
! samples/label/demo_2.prg
+ Added OnClick to show usage
! fixed some XBase code problem
; TODO problem with XBase syntax ACTION|ONCLICK. Must be fixed

! source/label.prg
+ Added OnClick() event.
+ Added ProcessMouseKey() to handle mouse button.

! samples/textbox/demo_1.prg
! samples/textbox/demo_2.prg
+ Added OnEnter to show usage
! fixed some XBase code problem
; demo_2.prg can't be compiled with /w3 flag. problem with "OCURRENTWINDOW"
; var name used by commands MENU....
; TODO all menu manager must be rewrite without use memvar

! source/textbox.prg
! Fixed OnEnter() method. Textbox require a different event code
+ Added ProcessEnter() method to handle ENTER
* simple restyling

! source/control.prg
! Fixed OnEnter() method
+ Added ProcessKeyPressed() method to handle keyboard ENTER. It's generic
* simple restyling

* source/baisc.prg
+ add SendEvent() method

* source/hmgapp.prg
+ add CurrQtWin() method to know current QT window
A) Now we have OnEnter over Texbox with automated skipping to the next control.
B) Now we have OnClick over Label, but while with OOP there isn't problem with XBase syntax (ACTION|ONCLICK)
yes. I don't investigate any more.
C) We can know the QT window active ( see HMGAPP():CurrQtWin() )

About OnEnter and OnClick, there is the possibility to activate them everywhere (Form, Label, Button, ecc.) but: code must be fixed in a different way (ie bOnter must be moved from "control.prg" to "basic.prg" and every object can have a different way to handle button pressed).

Best regards.