Bane Posted September 22, 2009 Share Posted September 22, 2009 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 Quote Link to comment Share on other sites More sharing options...
JohnM Posted September 22, 2009 Share Posted September 22, 2009 use (mode_tile "your tile here" 2) to set focus to that tile when the program starts. then you will have to use the tab key to go to the next tile. Quote Link to comment Share on other sites More sharing options...
Bane Posted September 22, 2009 Author Share Posted September 22, 2009 Thanks for this. It's the solution for one part of my question. So, no way for using ENTER button? Quote Link to comment Share on other sites More sharing options...
JohnM Posted September 22, 2009 Share Posted September 22, 2009 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. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 22, 2009 Share Posted September 22, 2009 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. Quote Link to comment Share on other sites More sharing options...
Bane Posted September 23, 2009 Author Share Posted September 23, 2009 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. Quote Link to comment Share on other sites More sharing options...
MSasu Posted September 23, 2009 Share Posted September 23, 2009 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, Quote Link to comment Share on other sites More sharing options...
Bane Posted September 23, 2009 Author Share Posted September 23, 2009 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... 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. Quote Link to comment Share on other sites More sharing options...
MSasu Posted September 24, 2009 Share Posted September 24, 2009 Thanks for the comments! I’m happy that was able to help you. Quote Link to comment Share on other sites More sharing options...
MSasu Posted September 24, 2009 Share Posted September 24, 2009 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, Quote Link to comment Share on other sites More sharing options...
Bane Posted September 24, 2009 Author Share Posted September 24, 2009 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? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 24, 2009 Share Posted September 24, 2009 It could be there is a problem elsewhere in the program, run a debug in the Visual LISP Editor to see where the program crashes Quote Link to comment Share on other sites More sharing options...
Bane Posted September 24, 2009 Author Share Posted September 24, 2009 If I remove that line, I got no errors... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 24, 2009 Share Posted September 24, 2009 Just curious is the tile key being recognised as a string in the Visual LISP Editor? (i.e. pink) Quote Link to comment Share on other sites More sharing options...
Bane Posted September 24, 2009 Author Share Posted September 24, 2009 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 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 24, 2009 Share Posted September 24, 2009 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.