OnEnter, ActiveWindow, SendEvent....

Moderator: Rathinagiri

Post Reply
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

OnEnter, ActiveWindow, SendEvent....

Post 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
Attachments
Test.zip
source code
(3.86 KiB) Downloaded 212 times
Luigi from Italy
www.L3W.it
User avatar
pctoledo
Posts: 123
Joined: Wed Aug 25, 2010 10:45 am
Location: Araçatuba - SP - Brazil
Contact:

Re: OnEnter, ActiveWindow, SendEvent....

Post by pctoledo »

This solution will not added in HMG4?
Regards/Saludos,

Toledo

Clipper On Line
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: OnEnter, ActiveWindow, SendEvent....

Post 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
Luigi from Italy
www.L3W.it
User avatar
pctoledo
Posts: 123
Joined: Wed Aug 25, 2010 10:45 am
Location: Araçatuba - SP - Brazil
Contact:

Re: OnEnter, ActiveWindow, SendEvent....

Post by pctoledo »

Ok Luigi.. I'll wait ... thanks!
Regards/Saludos,

Toledo

Clipper On Line
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: OnEnter, ActiveWindow, SendEvent....

Post 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.
User avatar
concentra
Posts: 256
Joined: Fri Nov 26, 2010 11:31 am
Location: Piracicaba - Brasil

Re: OnEnter, ActiveWindow, SendEvent....

Post by concentra »

mrduck wrote:I'm against the multiple inheritance if not strictly strictly necessary.
Me too.
[[]] Mauricio Ventura Faria
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: OnEnter, ActiveWindow, SendEvent....

Post by l3whmg »

Hi guys,
please do not shoot me too :lol:
Cheers
Luigi from Italy
www.L3W.it
User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: OnEnter, ActiveWindow, SendEvent....

Post 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.
Luigi from Italy
www.L3W.it
Post Reply