UP, DOWN arrow keys pressed in xBrowse

User avatar
fraxzi
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines
Contact:

UP, DOWN arrow keys pressed in xBrowse

Post by fraxzi »

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
frose
Posts: 327
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Gütersloh
Contact:

Re: UP, DOWN arrow keys pressed in xBrowse

Post by frose »

Fraxzi,

modifying the METHOD KeyDown() in xbrowse.prg works for me. For example I wanted to trap the key VK_TAB:

Code: Select all

CASE nKey == VK_TAB
      My_Tab()
 
User avatar
fraxzi
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines
Contact:

Re: UP, DOWN arrow keys pressed in xBrowse

Post by fraxzi »

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

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
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: UP, DOWN arrow keys pressed in xBrowse

Post by James Bott »

Fraxzi,

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

James
User avatar
fraxzi
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines
Contact:

Re: UP, DOWN arrow keys pressed in xBrowse

Post by fraxzi »

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
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: UP, DOWN arrow keys pressed in xBrowse

Post by James Bott »

Code: Select all

#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
fraxzi
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines
Contact:

Re: UP, DOWN arrow keys pressed in xBrowse

Post by fraxzi »

James Bott wrote:

Code: Select all

#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
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: UP, DOWN arrow keys pressed in xBrowse

Post by James Bott »

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
frose
Posts: 327
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Gütersloh
Contact:

Re: UP, DOWN arrow keys pressed in xBrowse

Post by frose »

James,

thank you very much for this tip, how to use inheritance and subtyping, polymorphism or overriding. How easy OOP can be ;-)
User avatar
fraxzi
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines
Contact:

Re: UP, DOWN arrow keys pressed in xBrowse

Post by fraxzi »

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

...
   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
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: UP, DOWN arrow keys pressed in xBrowse

Post by Enrico Maria Giordano »

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

EMG
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: UP, DOWN arrow keys pressed in xBrowse

Post by nageswaragunupudi »

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

SET XBROWSE TO MyBrowse()
or

Code: Select all

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
anserkk
Posts: 1280
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: UP, DOWN arrow keys pressed in xBrowse

Post by anserkk »

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
Post Reply