UP, DOWN arrow keys pressed in xBrowse

UP, DOWN arrow keys pressed in xBrowse

Postby fraxzi » Fri Nov 06, 2009 7:04 am

Hello All,

I use bKeyDown and bKeyChar but I cant trap the UP and DOWN arrow keys..

No problem If using mouse to navigate but if UP,DOWN keys are pressed?



Regards,
Fraxzi
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: UP, DOWN arrow keys pressed in xBrowse

Postby frose » Fri Nov 06, 2009 7:23 am

Fraxzi,

modifying the METHOD KeyDown() in xbrowse.prg works for me. For example I wanted to trap the key VK_TAB:
Code: Select all  Expand view
CASE nKey == VK_TAB
      My_Tab()
 
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
User avatar
frose
 
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg

Re: UP, DOWN arrow keys pressed in xBrowse

Postby fraxzi » Fri Nov 06, 2009 7:42 am

frose wrote:Fraxzi,

modifying the METHOD KeyDown() in xbrowse.prg works for me. For example I wanted to trap the key VK_TAB:
Code: Select all  Expand view
CASE nKey == VK_TAB
      My_Tab()
 



Thanks Frose!

as-much-as possible not to modify the original class so I wont forget the modification after an upgrade...
That would be the last resort.


Regards,
Fraxzi
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: UP, DOWN arrow keys pressed in xBrowse

Postby James Bott » Fri Nov 06, 2009 3:58 pm

Fraxzi,

You will have to subclass xbrowse and create a new keyDown() method.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: UP, DOWN arrow keys pressed in xBrowse

Postby fraxzi » Mon Nov 09, 2009 12:22 am

Thanks James,

Do you have a sample I can start with?


Fraxzi
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: UP, DOWN arrow keys pressed in xBrowse

Postby James Bott » Mon Nov 09, 2009 12:29 am

Code: Select all  Expand view
#include "fivewin.ch"
#include "vkey.ch"

CLASS MyBrowse from TXBrowse
   method KeyDown()
endclass

Method KeyDown( nKey, nFlags ) CLASS MyBrowse

  do case
     case nKey == VK_UP
        // do whatever
     case nKey == VK_DOWN
        // do whatever
  enddo

return super:keyDown( nKey, nFlags )
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: UP, DOWN arrow keys pressed in xBrowse

Postby fraxzi » Mon Nov 09, 2009 8:54 am

James Bott wrote:
Code: Select all  Expand view
#include "fivewin.ch"
#include "vkey.ch"

CLASS MyBrowse from TXBrowse
   method KeyDown()
endclass

Method KeyDown( nKey, nFlags ) CLASS MyBrowse

  do case
     case nKey == VK_UP
        // do whatever
     case nKey == VK_DOWN
        // do whatever
  enddo

return super:keyDown( nKey, nFlags )



Hello James,

Thank you for the reply.

with the above, can I alter the Method Keydown() on an already created object TXBrowse?


Regards,
Fraxzi
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: UP, DOWN arrow keys pressed in xBrowse

Postby James Bott » Mon Nov 09, 2009 1:32 pm

Fraxzi,

with the above, can I alter the Method Keydown() on an already created object TXBrowse?


Well, you have to use MyBrowse instead of TXBrowse, but other than the way you call it:

Instead of:

oBrw:= TXBrowse():new( oWnd )

You use:

oBrw:= MyBrowse():new( oWnd )

The syntax is exactly the same as TXBrowse (because everything else is TXBrowse code). So the only code you need to change is the above line.

You may want to read the Introduction to Object Oriented Programming articles on my website for a better understanding of OOP and subclassing.

http://www.gointellitech.com/program.htm

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: UP, DOWN arrow keys pressed in xBrowse

Postby frose » Mon Nov 09, 2009 2:42 pm

James,

thank you very much for this tip, how to use inheritance and subtyping, polymorphism or overriding. How easy OOP can be ;-)
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86
User avatar
frose
 
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg

Re: UP, DOWN arrow keys pressed in xBrowse

Postby fraxzi » Tue Nov 10, 2009 1:25 am

James Bott wrote:Fraxzi,

with the above, can I alter the Method Keydown() on an already created object TXBrowse?


Well, you have to use MyBrowse instead of TXBrowse, but other than the way you call it:

Instead of:

oBrw:= TXBrowse():new( oWnd )

You use:

oBrw:= MyBrowse():new( oWnd )

The syntax is exactly the same as TXBrowse (because everything else is TXBrowse code). So the only code you need to change is the above line.

You may want to read the Introduction to Object Oriented Programming articles on my website for a better understanding of OOP and subclassing.

http://www.gointellitech.com/program.htm

Regards,
James




Thank you so much for the great idea! :wink:

I did this to preserved my predefined xBrowse:

Code: Select all  Expand view

...
   REDEFINE XBROWSE oBrw ID 1023 OF oDlg;
                  AUTOSORT UPDATE AUTOCOLS FASTEDIT LINES CELL;
                  ARRAY { {'Test'} };
                  CLASS MyxBrowse()
...

CLASS MyxBrowse from TXBrowse
   METHOD KeyDown( nKey, nFlags )
ENDCLASS

METHOD KeyDown( nKey, nFlags ) CLASS MyxBrowse

  DO CASE
     CASE nKey == VK_UP
        // do whatever
          msginfo( 'Up Key' test )
     CASE nKey == VK_DOWN
        // do whatever
  ENDCASE

RETURN Super:KeyDown( nKey, nFlags )
...
 



It works like magic! I wouldn't discover this without your input.

Thanks so much!
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: UP, DOWN arrow keys pressed in xBrowse

Postby Enrico Maria Giordano » Tue Nov 10, 2009 8:34 am

Unfortunately the name of the original class is used inside various FWH sources and this prevents the full working inheritance.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8336
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: UP, DOWN arrow keys pressed in xBrowse

Postby nageswaragunupudi » Tue Nov 10, 2009 10:51 am

Enrico Maria Giordano wrote:Unfortunately the name of the original class is used inside various FWH sources and this prevents the full working inheritance.

EMG


I think this is not correct. XBrowse is intentionally coded to enable use of Inherited classes.

If we use the the statement
Code: Select all  Expand view
SET XBROWSE TO MyBrowse()

or
Code: Select all  Expand view
SetXBrowse( { || MyBrowse() }

the entire FWH library will use MyBrowse() instead of TXBrowse()
What is hardcoded is TXBrows() not TXBrowse(). TXBrows() by default returns TXBrowse() and when SetXBrowse( ... ) is executed, TXBrows() returns the new class not the parent TXBrowse() class.

After executing the above statement, all commands work with the MyBrowse() instead of TXBrowse()

But I noticed some bugs if we change different child classes within the same program. From my experience I advise using SET XBROWSE TO command at the beginning of the program.

Using the clause CLASS for each browse is supposed to use the child class only for that browse, but I faced some problems in its working.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10255
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: UP, DOWN arrow keys pressed in xBrowse

Postby Enrico Maria Giordano » Tue Nov 10, 2009 11:06 am

Please search for the string "txbrowse" inside FWH source code.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8336
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: UP, DOWN arrow keys pressed in xBrowse

Postby anserkk » Tue Nov 10, 2009 11:27 am

Please search for the string "txbrowse" inside FWH source code.

Out of 105 references, 102 reference are in xBrowse.Prg itself and 1 reference in btnbmp.prg, 1 in database.prg and 1 in Dialog.prg

Regards
Anser
User avatar
anserkk
 
Posts: 1330
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: UP, DOWN arrow keys pressed in xBrowse

Postby Enrico Maria Giordano » Tue Nov 10, 2009 11:46 am

Exactly. The problem are the ones in btnbmp.prg, database.prg and dialog.prg.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8336
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 15 guests