Jump to content

dcl edit boxes


Bane

Recommended Posts

Hello,

I am trying to write my very first dcl file... Is there any way to move cursor over edit boxes using ENTER keyboard button (not tab), something like TabIndex in Visual Basic?

 

After lsp file started I want cursor to be positioned in the first edit box and after I write some value there I want to go to the next edit box using enter button... After 3 or 4 edit boxes, cursor should be positioned on OK button waiting for me to press enter again...

 

Any suggestion is welcome.

 

Thanks

Link to comment
Share on other sites

i don't think so,

when you tab down to the OK button you would hit enter to start the program, so if you could use the enter for tab how could you start the program with out having to use the mouse to click the button.

 

i never had an issue with the tab key, my left hand is always there anyway.

Link to comment
Share on other sites

I very much doubt you will be able to have control over the mouse - a much lower-level programming language than LISP would be needed for this functionality.

 

That's what I thought. It can be VB, at least.

Thank you all.

Link to comment
Share on other sites

Actually you can do navigation between dialog fields using (from keyboard only) – please try the code below:

Save as test_dclnavigate.dcl file on AutoCAD’s search path:

 
TESTDIALOG : dialog {
: edit_box { key = "EditBox1st"; label = "1st Edit Box: "; allow_accept = false; edit_width = 12;}
: edit_box { key = "EditBox2nd"; label = "2nd Edit Box: "; allow_accept = false; edit_width = 12;}
: edit_box { key = "EditBox3rd"; label = "3rd Edit Box: "; allow_accept = false; edit_width = 12;}

ok_only;
}

Save as test_dclnavigate.lsp file:

 
(defun TestDialogNavigate()

(setq CodDialog (load_dialog "test_dclnavigate.dcl"))
(if (not (new_dialog "TESTDIALOG" CodDialog)) (exit))

(mode_tile "EditBox1st" 2)                                  ;set initial focus to first edit box
(action_tile "EditBox1st" "(mode_tile \"EditBox2nd\" 2)")   ;switch focus from first to second
(action_tile "EditBox2nd" "(mode_tile \"EditBox3rd\" 2)")   ;switch focus from second to third
(action_tile "EditBox3rd" "(mode_tile \"accept\" 2)")       ;set final focus from third to OK

(action_tile "accept" "(done_dialog 1)")
(start_dialog)
(unload_dialog CodDialog)

(princ)
)

In your code don’t forget to set allow_accept attribute to false for all fields included in navigation.

Regards,

Link to comment
Share on other sites

Actually you can do navigation between dialog fields using (from keyboard only) – please try the code below:

 

In your code don’t forget to set allow_accept attribute to false for all fields included in navigation.

 

Regards,

 

 

That easy!!! Bravo!!! That is what I want. Really good job. Thanks a lot.

 

I made my code of all suggestions found here, it's work fine for me.

It needs some more makeup... :roll:

I added a list_box and list layers names there so user can choose the working layer. After pressing on ok button point is drawn along with its number (for example), and dialog comes up again for next point.

I saved chosen layer name to variable, but is there any way to set that layer name as default (current) for next entry by highlighting it in list box automatically? Question is: how to highlight layer name stored in variable, in listbox?

 

Thanks msasu again for the great peace of code.

Link to comment
Share on other sites

Question is: how to highlight layer name stored in variable, in listbox?

 

In order to highlight an entry in a list box or pop-up list you should find first if your default value is stored in that list and his index (position in list, first entry being index 0). Next, when load the dialog, highlight it by:

 

(set_tile “MyListBox” (itoa ItemIndexInList))

 

Take care that set_tile statement accepts only strings as arguments; providing nil as second argument will raise a fatal error!

 

Regards,

Link to comment
Share on other sites

In order to highlight an entry in a list box or pop-up list you should find first if your default value is stored in that list and his index (position in list, first entry being index 0). Next, when load the dialog, highlight it by:

 

(set_tile “MyListBox” (itoa ItemIndexInList))

Take care that set_tile statement accepts only strings as arguments; providing nil as second argument will raise a fatal error!

 

Regards,

 

I stored Layer index in variable and it's ok when I check it by !sStr. I got "2" for example. So sStr is already a string.

If I write like this:

(set_tile “layerList” sStr);

I got error:

error: bad argument type: stringp nil

 

On the other hand if I write like:

(set_tile “layerList” (itoa sStr));

I got error:

error: bad argument type: fixnump: "2"

 

layerList is the key of list_box in dcl file.

 

Where is the problem?

Link to comment
Share on other sites

Yes it is... But I found what is wrong... I copied msasus' code

(set_tile “MyListBox” (itoa ItemIndexInList))to clipboard and just paste it to my code. I use NotePad for editing lisp files. I changed MyListBox and ItemIndexInList to my variables, leaving this quotation marks intact. NotePad shows quotation marks as they are here, but in Visual Lisp editor, there were no quotation marks... there were two little black boxes... I just change that...

 

So, thank you for your advice to try with VLISP, I would never find this error in notepad...

Life can be so complicated sometimes...

 

Thanks again

Link to comment
Share on other sites

I always use the Visual LISP Editor to create my LISP files - the syntax highlighting is indispensable - protected symbols are shown, meaning you can avoid naming your variables incorrectly.

 

More info on how to use the Visual LISP Editor can be found here:

 

http://www.afralisp.net/vl/vl-edit.htm

 

http://www.afralisp.net/vl/vlisp.htm

 

http://midpointcad.com/au/docs/lakose_The_Visual_LISP_Developers_Bible.pdf

 

 

If you wanted to stick to the theme of Notepad, check out Notepad++ ~ free code editing software:

http://notepad-plus.sourceforge.net/uk/site.htm

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...