How to change behavior of pressing <Enter> in XBrowse?

How to change behavior of pressing <Enter> in XBrowse?

Postby Max HK » Sat Aug 31, 2019 3:42 am

In XBrowse, the default behavior of pressing <Enter> is going to next column. If lFastEdit is .T., it goes to edit current cell.

But I want to call my user defined function after user presses <Enter>. Furthermore, depending on the row cell stayed, different functions can be called. eg. in "Customer Code" column, function to display dialog for editing current record; in "Name" column, function to display many customer photos and business card; in "Web site" column, it displays company site by Google; in "Outstanding Amount" column, I can display the purchase history.

I do not want to use Buttons in ButtonBar. My target is user can operate the program all by keyboard, with minimum usage of moving mouse and mouse-click.

Thanks.
Max HK
 
Posts: 23
Joined: Wed Oct 15, 2008 1:04 pm

Re: How to change behavior of pressing <Enter> in XBrowse?

Postby nageswaragunupudi » Sat Aug 31, 2019 4:04 am

Code: Select all  Expand view  RUN
oBrw:bKeyDown := { |k| If( k == VK_RETURN, OnEnterKey( oBrw ), nil ) }

function OnEnterKey( oBrw )

   local oCol  := oBrw:SelectedCol()
   
   ? oCol:cHeader
   // your code depending on the selected column
   
return 0
 
Regards

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

Re: How to change behavior of pressing <Enter> in XBrowse?

Postby Max HK » Sat Aug 31, 2019 7:35 am

It works. Thanks.

But XBrowse still move to next column first and then call my function. May XBrowse keep staying on the same column? ie. do nothing and call OnEnterKey(oBrw) immediately.
Max HK
 
Posts: 23
Joined: Wed Oct 15, 2008 1:04 pm

Re: How to change behavior of pressing <Enter> in XBrowse?

Postby nageswaragunupudi » Sat Aug 31, 2019 10:50 am

Max HK wrote:But XBrowse still move to next column first and then call my function. May XBrowse keep staying on the same column? ie. do nothing and call OnEnterKey(oBrw) immediately.


Use bKeyChar instead of bKeyDown.
Code: Select all  Expand view  RUN
oBrw:bKeyChar := { |nKey,nFlags,oBrw,oCol| If( nKey == VK_RETURN, OnEnterKey( oBrw, oCol ), nil ) }

....

function OnEnterKey( oBrw, oCol )

   ? oCol:cHeader
   // your code

return 0  // important
 


Make sure you return 0 when your function exits.
Regards

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 55 guests