TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: alanjt on September 24, 2008, 12:00:49 PM
-
with DCL, what is the coding for when your dialog pops up and you make something else your active window, it won't close (as if you pressed ok)?
-
That sounds like normal behavior. The dialog should not close until the user closes it.
-
Sounds like you mean a Modal (floating) dialog. Can't be done with DCL.
Do a search for OpenDCL
-
oops, should have proofed what i typed. i DON'T want it to close, but if i have it open and switch to a different window it will act as if i pressed ok. i want to prevent it from acting this way; i only want it to close if i click ok or hit escape. sorry guys.
-
Yep, that's Modal behavior. DCL not going to provide that fuunctionality.
-
Yep, that's Modal behavior. DCL not going to provide that fuunctionality.
but it's the only DCL dialog i've ever seen do this.
i'm 100% with you on how awesome odcl is, i'm working on learning it. however, this is for something very simple, 1 edit box to type in a single string and an ok button, that's it. i use it as a subroutine that i can just setq a value from it.
-
oops, should have proofed what i typed. i DON'T want it to close, but if i have it open and switch to a different window it will act as if i pressed ok. i want to prevent it from acting this way; i only want it to close if i click ok or hit escape. sorry guys.
tHEN THERE IS SOMETHING ABOUT THIS DIALOG THAT IS CLOSING IT.
Darn Caps!
Are you using an OK_Cancel button? Or a button you made?
Can you post the DCL & lisp code?
-
oops, should have proofed what i typed. i DON'T want it to close, but if i have it open and switch to a different window it will act as if i pressed ok. i want to prevent it from acting this way; i only want it to close if i click ok or hit escape. sorry guys.
tHEN THERE IS SOMETHING ABOUT THIS DIALOG THAT IS CLOSING IT.
Darn Caps!
Are you using an OK_Cancel button? Or a button you made?
Can you post the DCL & lisp code?
lol, for a moment there, i really thought i had upset you.
here's the code, i don't know why i didn't just post it to begin with. i didn't create this, found it floating around here and just modified it a little.
(defun GetString-dlg (title str / dcl_id fn fo)
(setq fn (vl-filename-mktemp "" "" ".dcl"))
(setq fo (open fn "w"))
(setq ValueStr (strcat "value = \"" str "\";"))
(write-line (strcat "stringdlg : dialog {
label = \"" title "\";") fo)
(write-line ": edit_box {
label = \"\";
edit_width = 30;
key = \"stringdlg\";
is_default = true; " fo)
(write-line ValueStr fo)
(write-line "}" fo)
(write-line ": row {
alignment = centered;
fixed_width = true;
: button {
label = \"OK\";
key = \"dcl_accept\";
width = 10;
allow_accept = true;
}
}
}" fo)
(close fo)
(setq dcl_id (load_dialog fn))
(new_dialog "stringdlg" dcl_id)
(action_tile "stringdlg" "(setq str $value)(done_dialog)")
(start_dialog)
(unload_dialog dcl_id)
(vl-file-delete fn)
str
)
-
Allow_accept - Instead of selecting an item from the list and then the OK
button, this allows you to select by double-clicking the list item.
Change allow_accept to is_default
(defun GetString-dlg (title str / dcl_id fn fo)
(setq fn (vl-filename-mktemp "" "" ".dcl"))
(setq fo (open fn "w"))
(setq ValueStr (strcat "value = \"" str "\";"))
(write-line (strcat "stringdlg : dialog {
label = \"" title "\";") fo)
(write-line ": edit_box {
label = \"\";
edit_width = 30;
key = \"stringdlg\";" fo)
;is_default = true;
(write-line ValueStr fo)
(write-line "}" fo)
(write-line ": row {
alignment = centered;
fixed_width = true;
: button {
label = \"OK\";
key = \"dcl_accept\";
width = 10;
is_default = true;
}
}
}" fo)
(close fo)
(setq dcl_id (load_dialog fn))
(new_dialog "stringdlg" dcl_id)
(action_tile "stringdlg" "(setq str $value)(done_dialog)")
(start_dialog)
(unload_dialog dcl_id)
(vl-file-delete fn)
str
)
-
Another version, no Title though.
;;; FUNCTION
;;; Use ddedit box to edit a text string.
;;;
;;; ARGUMENTS
;;; txt = the text string
;;;
;;; USAGE
;;; text_edit
;;;
;;; PLATFORMS
;;; 2000+
;;;
;;; AUTHOR
;;; Charles Alan Butler
;;; ab2draft@TampaBay.rr.com
;;;
;;; VERSION
;;; 1.0 Oct. 06, 2004
(defun text_edit (txt / entlist ent)
(if (entmake
(list
'(0 . "TEXT")
(cons 10 '(0 0))
(cons 40 1)
(cons 7 (getvar "TEXTSTYLE"))
(cons 1 txt) ; Text String
)
)
(progn
(setq ent (entlast))
(command "._ddedit" ent "")
(setq txt (cdr (assoc 1 (entget ent))))
(entdel ent)
txt
)
)
)
(defun c:test (/ newtext)
(setq newtext (text_edit "This is a test string."))
)