Author Topic: Dialog Box Label  (Read 2698 times)

0 Members and 1 Guest are viewing this topic.

DanB

  • Bull Frog
  • Posts: 367
Dialog Box Label
« on: November 21, 2007, 10:57:44 AM »
Is it possible to use a lisp variable as part of the label for a dialog box? In the below code, I have a key which value is obtained from my lisp code, however I would like to put the "current_file" (simply a file name) in the title label. So the title could read something like "LISP Description for "Block-Erase.lsp".

Code: [Select]
test_DescrDialog : dialog {

label = "LISP Description"; // label for dialog box [color=blue]<<possible to add lisp variable here?[/color]
: spacer { width = 1; }
: row {
: text {
   label = "";
   key = "current_file"; // [color=blue]<< this holds the file name I want in the title[/color]
  } // end text
  } // end row
: row {      // description list box row
: list_box {
   width = 50;
   height = 24;
   key = "lisp_descr";
  } // list box
  } // end row

: row {          // defines the Done button row
  : spacer { width = 1; }
  : button {    // defines the Done button
    label = "Done";
    is_default = true;
    is_cancel = true;
    key = "done";
    width = 8;
    fixed_width = true;
  } // end row
  : spacer { width = 1;}
  }

} // end

Binky

  • Guest
Re: Dialog Box Label
« Reply #1 on: November 21, 2007, 11:50:33 AM »
Have you tried the Set_tile command?

Here are a couple quotes from the help file. 

"A dialog is the tile that defines the dialog box. You should not specify both a label and value attribute: the value attribute overrides the label attribute. "

"For a dialog, the label and value are equivalent except for layout considerations. To change the title at runtime, use the set_tile function (see set_tile in the AutoLISP Reference)."

Have not played with it, but I have seen what you are after done.

DanB

  • Bull Frog
  • Posts: 367
Re: Dialog Box Label
« Reply #2 on: November 21, 2007, 11:54:51 AM »
I will have a closer look at the set_tile command. Thanks.

Binky

  • Guest
Re: Dialog Box Label
« Reply #3 on: November 21, 2007, 12:24:08 PM »
I was messing around since you got me curious about it.  Give the Dialog a key and remove the label entry from the dcl file.  then use set_tile to assign a value to that key.

test-dlg : dialog
   key = "dialog-title";

(set_tile "dialog-title" your string here)

Hope this helps
Happy Thanksgiving!!!!

Adesu

  • Guest
Re: Dialog Box Label
« Reply #4 on: November 21, 2007, 07:32:23 PM »
Hi DanB
I guess you want like this maybe
Lsp File
Code: [Select]
(defun c:test (/ dcl_id ans opt)
   (setq opt (getstring t "\nEnter new name for title<Dialog With Variable>: "))
   (if (= opt "")(setq opt "Dialog With Variable"))
   (setq dcl_id (load_dialog "Dialog With Variable.DCL"))
   (if
      (not (new_dialog "eb" dcl_id))
      (exit)
      )
   (set_tile "dt" opt)
   (set_tile "eb1" "Adesu")
   (mode_tile "eb1" 2)
   (action_tile "eb1" "(setq data_box (get_tile \"eb1\"))")
   (action_tile "accept" "(done_dialog 1)")
   (setq ans (start_dialog))
   (if
      (= ans 1)
      (c:test)
      ;(alert  (strcat "\nYou just type " "\"" data_box "\""))
      ) ; if
   (princ)
   )    ; defun
Here DCL file
Code: [Select]
eb : dialog {label = " ";
             key = "dt";
   : row {
   : edit_box {label = "Fill with new string";
               key = "eb1";
               edit_width = 15;
               allow_accept = true;}}
    ok_only;}