See the top rated post in this thread. Click here

Results 1 to 8 of 8

Thread: clear list box in a dcl dialog box

  1. #1
    Member
    Join Date
    2015-01
    Posts
    43
    Login to Give a bone
    0

    Default clear list box in a dcl dialog box

    I have a dcl dialog box with an edit_box to enter a new value and a list_box to select existing values. I would like to implement the following functionality:

    - the list_box is cleared when a value is entered in the edit_box
    - the edit_box is cleared when a value is selected in the list_box

    Since the edit_box action_tile function is only fired when I leave the it, the only way to get the list_box to clear seems to be by picking a value in the list_box, which is self defeating.

    I suppose I could put in a 'Confirm New Value' button just to clear the list_box but that's a pretty excruciating hack.

    Has anyone figured out a better way to clear the list_box? As always, any help is greatly appreciated.

  2. #2
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: clear list box in a dcl dialog box

    Hi,

    Add the attribute allow_accept = true; to the edit_box tile then add an action_tile for the same edit_box's key then add the codes that fill the list_box tile with empty list to clear it.

    NOTE: You need to hit enter once you fill the value out in the fore-said edit_box to allow / force the action_tile to fire up.

    Good luck.

  3. #3
    Member
    Join Date
    2015-01
    Posts
    43
    Login to Give a bone
    0

    Default Re: clear list box in a dcl dialog box

    Thanks for the help Tharwat. I tested your suggestion with the following code:

    (action_tile "clear" "(set_tile \"ExistLayState\" \"\")")



    but it does not clear the selection. This code does work on the edit_box but not on the list_box. Do you have any idea what I'm doing wrong? This is not a multi-selection list by the way.

  4. #4
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: clear list box in a dcl dialog box

    Post the DCL codes that related to the edit_box and the list_box and the variable name that obtains the strings for the list_box if available.

  5. #5
    Member
    Join Date
    2015-01
    Posts
    43
    Login to Give a bone
    0

    Default Re: clear list box in a dcl dialog box

    Tharwat,
    Here is the code and the dcl definition. All of the indenting and backslashes get removed when I post but I hope this is still clear. Hitting the enter key after updating the edit_box doesn't work and even directly pressing the clear button doesn't work. Thanks for any help you may be able to offer.

    (defun #LO:SetLayerStateName (|XRefName / _LayerStatePrefix _NativeLayerStates _DialogID)
    (if (= |XRefName "Native")
    (setq _LayerStatePrefix (##HES:SetPOSXRefBlockName ~DrawingName))
    ;Else
    (setq _LayerStatePrefix |XRefName))

    (setq _NativeLayerStates (#LO:GetNativeLayerStates _LayerStatePrefix))
    ;.................................................................................

    (setq _DialogID (load_dialog "LayerState-Native.dcl"))
    (new_dialog "NativeLayerState" _DialogID "" (##HES:GetCursorPos 350 200 nil))

    (start_list "ExistLayState" 3)
    (mapcar 'add_list _NativeLayerStates)
    (end_list)

    (mode_tile "NewLayState" 2)

    (action_tile "NewLayState" "(setq ^LayerStateName (strcat _LayerStatePrefix " -- " $value))")
    (action_tile "ExistLayState" "(setq ^LayerStateName (nth (atoi $value) _NativeLayerStates)) (set_tile "NewLayState" "")")

    (action_tile "clear" "(set_tile "ExistLayState" "")")
    (action_tile "ok" "(if (layerstate-has ^LayerStateName) (layerstate-delete ^LayerStateName)) (done_dialog)
    (unload_dialog _DialogID)")
    (action_tile "cancel" "(done_dialog) (unload_dialog _DialogID) (exit)")

    (start_dialog)
    (unload_dialog _DialogID))



    NativeLayerState : dialog {
    label = "Select Layer State" ;

    : edit_box {
    key = "NewLayState" ;
    label = "New Layer State" ;
    allow_accept = true ;
    width = 60 ; }

    spacer_1 ;

    : list_box {
    key = "ExistLayState" ;
    label = "Existing Layer States" ;
    height = 15 ;
    width = 60 ; }

    : row {
    fixed_width = true ;

    : button {
    key = "ok" ;
    label = "ok" ;
    width = 8 ;
    fixed_width = true ; }

    : button {
    key = "cancel" ;
    label = "cancel" ;
    is_cancel = true ;
    fixed_width = true ;
    width = 8 ; }

    : button {
    key = "clear" ;
    label = "clear" ;
    is_default = true ;
    width = 8 ;
    fixed_width = true ; } } }

  6. #6
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    1

    Default Re: clear list box in a dcl dialog box

    Hi,

    Here is a working example regardless of your other functions that you did not include into the program.
    NOTE: You don't need to the CLEAR button now unless you want it for something else and I also disabled the 'OK' button since that I don't know that those functions that are included into this action_tile do.

    Code:
    (defun c:test (/ _LayerStatePrefix  _NativeLayerStates  _DialogID additems  run lst )
      (defun additems (items)
        (start_list "ExistLayState")
        (mapcar 'add_list items)
        (end_list)
      )
      ;;		;;
      (setq run nil)
      (if (and (setq _DialogID
                      (load_dialog "NativeLayerState.dcl"
                      )
               )
               (< 0 _DialogID)
          )
        (while
          (not
            (cond
              ((not (new_dialog "NativeLayerState" _DialogID))
               (princ "\nDialog couldn't be loaded.")
              )
              ((progn (mode_tile "NewLayState" 2)
                 (action_tile
                        "NewLayState"
                        "(setq lst (list (get_tile \"NewLayState\")))"
                      )
                      (action_tile
                        "ExistLayState"
                        "(set_tile \"NewLayState\" \"\") (setq lst nil)"
                      )
    ;;;(action_tile "ok" "(if (layerstate-has ^LayerStateName) (layerstate-delete ^LayerStateName))
    ;;;                   (setq done (done_dialog) )
    ;;;                   (unload_dialog _DialogID)")
                      (action_tile
                        "cancel"
                        "(setq run (done_dialog)) (unload_dialog _DialogID)"
                      )
                      (if lst
                        (additems lst)
                      )
                      (zerop (start_dialog))
               )
              )
              (run (unload_dialog _DialogID))
            )
          )
        )
      )
      (princ)
    )

  7. #7
    Member
    Join Date
    2015-01
    Posts
    43
    Login to Give a bone
    0

    Default Re: clear list box in a dcl dialog box

    Thanks for your help on this Tharwat. Your code gave me some insights that led to me getting the functionality I wanted. Also, I had never thought of using a cond statement as a while loop test like that. It's a great idea & I can already think of 5 or 6 programs that will be significantly cleaned up by using that structure. Thanks for that too.

  8. #8
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: clear list box in a dcl dialog box

    Great to hear that.

    You're welcome anytime.

Similar Threads

  1. DCL Dialog Box Create routine
    By peter in forum AutoLISP
    Replies: 7
    Last Post: 2019-10-28, 07:16 PM
  2. The Modify Multiline Style Dialog Box, Make Dialog Box Resizable
    By Wish List System in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2016-03-24, 03:25 PM
  3. .dcl dialog box questions
    By seth357792 in forum AutoLISP
    Replies: 1
    Last Post: 2013-03-01, 10:03 PM
  4. Replies: 2
    Last Post: 2006-09-07, 10:17 AM
  5. DCL - Button that would pick a point in AutoCAD in DCL
    By katkinson0082914 in forum AutoLISP
    Replies: 3
    Last Post: 2006-06-09, 12:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •