Viva Clipper !

SetKey()

Advertisements

Template

Class

Name

SetKey()

Category

TBrowse Method

Oneliner

Get an optionaly Set an new Code block associated to a inkey value

Syntax

      SetKey(<nKey>[,<bBlock>]) --> bOldBlock

Arguments

<nKey> An valid inkey Code

<bBlock> An optional action to associate to the inkey value.

Returns

<bOldBlock> If an Keypress has it code block changes, it will return the previus one; otherwise, it will return the current one

Description

This method Get an optionaly set an code block that is associated to an inkey value. The table below show the default keypress/Code Block definitions

      Inkey Value    Code Block

      K_DOWN         {| oB, nKey | oB:Down(), 0 }
      K_END          {| oB, nKey | oB:End(), 0 }
      K_CTRL_PGDN    {| oB, nKey | oB:GoBottom(), 0 }
      K_CTRL_PGUP    {| oB, nKey | oB:GoTop(), 0 }
      K_HOME         {| oB, nKey | oB:Home(), 0 }
      K_LEFT         {| oB, nKey | oB:Left(), 0 }
      K_PGDN         {| oB, nKey | oB:PageDown(), 0 }
      K_PGUP         {| oB, nKey | oB:PageUp(), 0 }
      K_CTRL_END     {| oB, nKey | oB:PanEnd(), 0 }
      K_CTRL_HOME    {| oB, nKey | oB:PanHome(), 0 }
      K_CTRL_LEFT    {| oB, nKey | oB:PanLeft(), 0 }
      K_CTRL_RIGHT   {| oB, nKey | oB:PanRight(), 0 }
      K_RIGHT        {| oB, nKey | oB:Right(), 0 }
      K_UP           {| oB, nKey | oB:Up(), 0 }
      K_ESC          {| oB, nKey | -1 }

The keys handlers can be queried, added and replace an removed from the internal keyboard dictionary. See the example.

oTb:SetKey( K_TAB, {| oTb, nKey | -1 } )

An default key handler can be declared by specifyin a value of 0 for <nKey>. It associate code block will be evaluated each time TBrowse:Applykey() is called with an key value that is not contained in the dictionary. For example

oTb:SetKey( 0, {| oTb, nKey | DefKeyHandler( otb, nkey } ) This call the a function named DefKeyHandler() when nKey is not contained in the dictionary.

To remove an keypress/code block definition, specify NIL for <bBlock> oTb:SetKey( K_ESC, NIL )

Examples

      oTb:SeyKey( K_F10, {| otb, nkey | ShowListByname( otb ) }
Advertisements

Advertisements