Author Topic: RT tile enable / disable  (Read 871 times)

0 Members and 1 Guest are viewing this topic.

XXL66

  • Newt
  • Posts: 99
RT tile enable / disable
« on: December 09, 2015, 03:18:15 AM »
Hello

I made this dos_getstring alternative based on "List Box" from  Lee Mac (thx Lee!).
It works fine but a small difference is that with dos_getstring whenever you enter something in the edit box the accept tile is enabled immediatly, with this version you have to enter or click again before the tile gets updated.
Does anyone have a solution or workaround to get the same result ?
I could add an error tile maybe and leave the OK box enabled, and when the edit is empty display an error when selecting OK. However i like the disabled/enabled ok button interface.

ty !

Code: [Select]
;; Displays a DCL list box allowing the user to enter a string
(defun @main_dcl-GetString (tit$ msg$ / dch des tmp rtn)
  (cond
    ((not
       (and
(setq tmp (vl-filename-mktemp nil nil ".dcl"))
(setq des (open tmp "w"))
(write-line 
   (strcat
     "GetString:dialog{initial_focus=\"list\";label=\"" tit$
     "\";spacer;" ":text{key=\"TXT\";label=\"" msg$ "\";}"
     ":edit_box{key=\"list\";width=40;}spacer;ok_cancel;}"
    )
   des
)
(not (close des))
(< 0 (setq dch (load_dialog tmp)))
(new_dialog "GetString" dch)
       )
     )
     (prompt "\nError Loading GetString Dialog.")
    )
    (t
     (set_tile "list" "")
     (mode_tile "accept" 1)
     (action_tile "list" "(@main_dcl-focus_GetString $value)")
     (setq rtn
    (if (= (start_dialog) 1)
      rtn
    )
     )
    )
  )
  (if (< 0 dch)
    (unload_dialog dch)
  )
  (if (and tmp (setq tmp (findfile tmp)))
    (vl-file-delete tmp)
  )
  rtn
)


(defun @main_dcl-focus_GetString ($val / )
  (setq rtn $val)
  (if (/= rtn "")
    (mode_tile "accept" 0)
    (mode_tile "accept" 1)
  )
)

roy_043

  • Water Moccasin
  • Posts: 1747
  • BricsCAD 18
Re: RT tile enable / disable
« Reply #1 on: December 09, 2015, 04:05:41 AM »
As far as I know this is not possible. I have tried looking at the $reason value in the edit_box callback, but that does not help. In this situation I would leave the OK button enabled.

An interesting option is to set the allow_accept attribute to true for the edit_box.
When an edit_box has the attribute allow_accept with value true, hitting enter when the edit_box has focus will trigger the default button of the dcl dialog.

XXL66

  • Newt
  • Posts: 99
Re: RT tile enable / disable
« Reply #2 on: December 09, 2015, 04:30:32 AM »
interesting ! Thx Roy !

XXL66

  • Newt
  • Posts: 99
Re: RT tile enable / disable
« Reply #3 on: December 09, 2015, 04:44:51 AM »
Another problem with a dos_proplist alternative:

This function also works with association lists

f.e. (setq x '(("Title" . "Floorplan") ("Project" . "Project A")))

I would like that whenever the user selects another item from the list that the focus is on the edit box and that the content is selected.
Normally achieved with mode_tile 3.

This does not seem to work ?  What am I missing ?

Notice the allow_accept; ;-)
 
Code: [Select]
;; Displays a DCL list box allowing the user to enter a string
(defun @main_dcl-PropList (tit$ msg$ lst / dch des tmp rtn lsel )
  (cond
    ((not
       (and
(setq tmp (vl-filename-mktemp nil nil ".dcl"))
(setq des (open tmp "w"))
(write-line
   (strcat
     "PropList:dialog{initial_focus=\"edit\";label=\"" tit$
     "\";spacer;" ":text{key=\"TXT\";label=\"" msg$ "\";}"
     ":list_box{key=\"list\";width=40;tabs=\"20\";}"
     ":edit_box{key=\"edit\";width=40;allow_accept=true;}spacer;ok_cancel;}"
    )
   des
)
(not (close des))
(< 0 (setq dch (load_dialog tmp)))
(new_dialog "PropList" dch)
       )
     )
     (prompt "\nError @main_dcl loading PropList dialog.")
    )
    (t
     (@main_dcl-UpdateList lst)
     (setq lsel "0")
     (set_tile "list" lsel)
     (set_tile "edit" (cdr (nth (fix (atof lsel)) lst)))
     (action_tile
       "list"
       "(set_tile \"edit\" (cdr (nth (fix (atof (setq lsel $value))) lst)))) (mode_tile \"edit\" 3)"
     )
     (action_tile
       "edit"
       "(setq lst (@main_dcl-ListReplace lst (fix (atof lsel)) (cons (car (nth (fix (atof lsel)) lst)) $value)))(@main_dcl-UpdateList lst)"
     )
     (setq rtn
    (if (= (start_dialog) 1)
      lst
      nil
    )
     )
    )
  )
  (if (< 0 dch)
    (unload_dialog dch)
  )
  (if (and tmp (setq tmp (findfile tmp)))
    (vl-file-delete tmp)
  )
  rtn
)

(defun @main_dcl-ListReplace ( alist position newitem / i )
    (setq i -1)
    (mapcar '(lambda (x) (if (= position (setq i (1+ i))) newitem x)) alist)
)

(defun @main_dcl-UpdateList (lst / l)
  (start_list "list")
  (foreach l lst
    (add_list (strcat (car l) "\t" (cdr l)))
  )
  (end_list)
)

roy_043

  • Water Moccasin
  • Posts: 1747
  • BricsCAD 18
Re: RT tile enable / disable
« Reply #4 on: December 09, 2015, 05:29:21 AM »
You have a ')' too many in (action_tile "list" ...).
I prefer to create a small nested function for every action. This ensures that the code is displayed with proper syntax highlighting.
Code - Auto/Visual Lisp: [Select]
  1. (action_tile "list" "(N_ActionList)")

roy_043

  • Water Moccasin
  • Posts: 1747
  • BricsCAD 18
Re: RT tile enable / disable
« Reply #5 on: December 09, 2015, 05:30:33 AM »
BTW: What is the meaning of 'RT'?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: RT tile enable / disable
« Reply #6 on: December 09, 2015, 05:40:18 AM »
I'd assumed Real Time.

but you know the story about assumptions  :-D
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

XXL66

  • Newt
  • Posts: 99
Re: RT tile enable / disable
« Reply #7 on: December 09, 2015, 05:43:58 AM »
oops.

Real Time indeed