[LISP | DCL] edit_box and "keypress"

[LISP | DCL] edit_box and "keypress"

iBlachu
Advocate Advocate
1,169 Views
17 Replies
Message 1 of 18

[LISP | DCL] edit_box and "keypress"

iBlachu
Advocate
Advocate

Hi,

 

Is it possible to trigger something like (alert 'A') after each key press in an edit_box control?

0 Likes
1,170 Views
17 Replies
Replies (17)
Message 2 of 18

pkenewell6347
Advocate
Advocate

Unfortunately no. not with DCL. Something has to take focus away from the tile for it to process (Like ENTER or Tab).

Message 3 of 18

paullimapa
Mentor
Mentor

Explain “key press” and show us what you have in your action statement for that edit box now


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 4 of 18

iBlachu
Advocate
Advocate

What I want is to call any function after each keystroke in edit_box.

0 Likes
Message 5 of 18

paullimapa
Mentor
Mentor

I'm not aware of a way to invoke another function inside an edit box when you use the keyboard to enter a letter


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 6 of 18

ec-cad
Collaborator
Collaborator

Are you looking to count keystrokes ?

If so, count the length of the default strings on dialog open, then on exit, count all again.

IF old count /= new count... alert away

 

ECCAD

Message 7 of 18

Sea-Haven
Mentor
Mentor

You can run a defun based on changing a edit box but it can not accept any user input pick point etc, if you want that then you have to close the dcl and say reopen it.

Message 8 of 18

scot-65
Advisor
Advisor

@iBlachu 

 

Short answer is no. Documentation states it could be done but I never got it to work.

 

A popular misconception among DCL developers is to blend gathering user input with program execution. Bad idea.

 

The proper way is to:

 

1. Gather user input (when the "accept" event is triggered),

 

2. Test user input (via some sort of COND gauntlet),

 

3. Save user input (as a LIST using ONE session gremlin for the current program),

 

4. Close the dialog, and

 

5. Execute.

 

If in the COND gauntlet one tile does not satisfy the requirements (example would be a letter was entered instead of an integer), Alert the user, MODE_TILE = 2 the tile, and return to the dialog by sending back a nil.

 

The following structure is a simple example (that is simplified):

Edit box "Edi01" expects an integer.

 

(action_tile "accept" "(if (MyProgn_GET) (done_dialog 1))")

 

(defun MyProgn_GET ()

 (cond

  ((not (distof (get_tile "Edi01"))) (alert "Edit Box expects an Integer") (mode_tile "Edi01" 2) nil) ;note that ATOI is not used. If it fails, ATOI returns 0 which is an integer!

 ;;a second test of Edi01 needed here to see if it is indeed an integer and not a REAL.

...

 (T (setq MyGremlin (list (get_tile "Edi01"))))

 );cond

);end MyProgn_GET

 

Another reoccurring issue I see in this forum is the tiles are not initialized. For example, a TOGGLE tile has 3 possible returns: "0", "1", and nil. Where nil is due to the tile is not initialized.

Edit boxes similar: empty string, string, and nil.

 

Between the new_dialog and start_dialog add a "Initialization" section and build the session gremlin (as a LIST) if it does not exist. From there populate (initialize) the [/ALL] interactive tiles (except BUTTON).

;** Initialize **

(or MyGremlin (setq MyGremlin (list "1")))

;** Set Tile **

(set_tile "Edi01" (nth 0 MyGremlin))

;** Mode Tile **

 

;** Action Tile **

(action_tile "accept" "(if (MyProgn_GET) (done_dialog 1))")

 

Any other action tile you develop will be for dialog display such as disabling a tile, row, or column, or to switch out the contents of a list box, set focus to another tile, initialize another dialog, etc. The action tile should not direct to an execution part of your code that does not relate to the dialog display.

 

When the dialog is reopened during the same editing session, the dialog will show the previous state the dialog was in.

 

Finally, when communicating with radio_buttons, add a key="Rad00" to the container that is holding the radio buttons and communicate with the container. Yes it is true that radio buttons do not require radio containers (row / column), but these containers are there for this reason.

 

Pop quiz next week.

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

Message 9 of 18

Sea-Haven
Mentor
Mentor

Thinking more about this if you put a value in a edit box you maybe can  call a child dcl that will appear over the current dcl, a dcl has an option "Paragraph" or just a simple child dcl with a label "Option A will be used". No answer at moment just an idea.

 

A child dcl Size is clicked.

SeaHaven_0-1738375012859.png

 

 

Message 10 of 18

iBlachu
Advocate
Advocate

I need to enter some text into the edit field and filter the items in the list after each pressed letter. This is a way to search with a filter.

0 Likes
Message 11 of 18

Sea-Haven
Mentor
Mentor

Are you saying enter A and it auto replaces with ABCDEF etc. 

0 Likes
Message 12 of 18

ec-cad
Collaborator
Collaborator

Here's my take on it. Put the Lisp / dcl / txt  files in the same folder, say C:/disk8

Load the Lisp - function call is GETITEM. You will have to edit the lisp to point to your path.

 

ECCAD

 

 

Message 13 of 18

ec-cad
Collaborator
Collaborator

Updated Testme.lsp, does Upper / Lower case sort.

If 'sorted_lst is empty, reloads it.

 

ECCAD

 

Message 14 of 18

Moshe-A
Mentor
Mentor

@iBlachu hi,

 

if there is a way to do what you want in AutoLISP maybe you ask  here >> OpenDCL Forum << 

if there isn't, then the solution is not in AutoLISP 🤔

 

Moshe

 

 

Message 15 of 18

iBlachu
Advocate
Advocate

Thank you all for your involvement, but in fact in DCL and LISP it is probably not possible to obtain control after each key press while being in the edit_box.

0 Likes
Message 16 of 18

scot-65
Advisor
Advisor

@iBlachu wrote:

I need to enter some text into the edit field and filter the items in the list after each pressed letter. This is a way to search with a filter.


The only way to do this in DCL is to have a list box for the "items", an edit box for your "some text" and a Button assigned to an action tile that will read the contents of the edit box, refine the list of items, and repopulate the list box with the refined list. The key is the button tile.

 

:button {key="But01"; label="&Refine";}

 

... after refining and repopulating, (mode_tile "Edi01" 2) to set focus back to the edit box.

 

Action_tile for edit boxes only works when entering the edit box tile. Not during and not afterwards.

Thinking out loud, one can add an attribute to the edit box allow_accept but you will have to build a separate "accept" for the OK button.

 

scot65_0-1738707755370.png

 

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 17 of 18

john.uhden
Mentor
Mentor

@scot-65 & @iBlachu ,

The only way I have found to retrieve one keystroke at a time is by using GRREAD, which I think cannot be used within a DCL structure.

John F. Uhden

0 Likes
Message 18 of 18

ec-cad
Collaborator
Collaborator

If OP is into visual-basic, maybe a Form, and OnKey ?

My post above (latest testme.lsp) is pretty close, but you still need to push the 'Sort List' button.

Not 'exactly' what OP wants.

ECCAD

0 Likes