Disabling mouse and using a keyboard-controlled cursor.

Question:

How can I disable the mouse and use a cursor controlled by the keyboard in my application?

Solution:

We do not recommend disabling the mouse completely in your E3 application. Our suggestion is that you simply do not use it. To do so, just keep the screen objects from using their Click events.

To create a keyboard-controlled cursor, you must use the screen’s KeyDown event:

  Sub TelaCursor_KeyDown(KeyCode, Shift)

There are four lines of script, one for each direction the cursor can move: up, down, left, right. You can use Select Case resource to find out which key was pressed:

  Select case KeyCode
  case 39  ‘RIGHT
    Item(“Cursor”).X =(Item(“Cursor”).X) + 200
 
  case 37  ‘LEFT
    Item(“Cursor”).X =(Item(“Cursor”).X) – 200

  case 40  ‘DOWN
    Item(“Cursor”).Y =(Item(“Cursor”).Y) + 200
 
  case 38  ‘UP
    Item(“Cursor”).Y =(Item(“Cursor”).Y) – 200

NOTE: “Cursor” object is not Windows’s mouse. It is any non-specified figure-object in E3.

Each key changes the cursor’s X or Y value. In this example, the cursor will move 200 HIMETRIC units each time the key is pressed. This value can be changed; just keep in mind that the higher its value, the higher the cursor’s sensibility.

To “click” with this cursor, use Enter button (case 13).

Attached to this article is an application illustrating these procedures, developed with E3 v 3.1 b. 270. Please notice that some other features were added to this script, such as screen limits (so that the cursor stays confined on the screen), and a scrollbar, to change the cursor’s sensibility without having to leave the application.

Attachments:

Keyboard.zip

Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

Your email address will not be published.Required fields are marked *