Greying out the ok button in dcl

Discussion in 'AutoCAD' started by T.Willey, Jul 20, 2004.

  1. T.Willey

    T.Willey Guest

    I have a routine that will update revision levels in drawings or just fix the highest revision to different information. It works great, but there is no restrictions on it.

    I want to grey out the "ok" button unless the on toggle button is not selected, or if it's selected then unless all three areas have stuff in them. I have tried a couple of ways, but I can't get it to work, and I didn't save the attempts because it locked up acad.

    Any help is appreciated.
    Tim
     
    T.Willey, Jul 20, 2004
    #1
  2. T.Willey

    ECCAD Guest

    Review Mode_tile

    (mode_tile key mode)

    Arguments

    key

    A string that specifies the tile. The key argument is case-sensitive.

    mode

    An integer that can be one of the following:

    0 Enable tile

    1 Disable tile

    2 Set focus to tile

    3 Select edit box contents

    4 Flip image highlighting on or off

    Return Values

    nil

    On the way into your routine, do:
    (mode_tile "accept" 1); grey out OK key
    .......
    Examine combination of var's or settings and determine
    if you want to set the OK back on.
    (If (and (= var1 1)(= var2 0))
    (mode_tile "accept" 0)
    )

    Bob
     
    ECCAD, Jul 20, 2004
    #2
  3. T.Willey

    dblaha Guest

    Assuming you are familiar with the mode_tile and action_tile functions...
    You can use variables to allow the toggle button and the three areas to check their collective status. Below is some example code to give you an idea of what I'm talking about:

    (mode_tile "accept" 1) ;; gray out the OK button
    (setq button_var nil
    area1_var nil
    area2_var nil
    area3_var nil
    )
    (action_tile "button1"
    "(setq button_var $value)
    (if (and (= button_var \"1\") area1_var area2_var area3_var)(mode_tile \"accept\" 0))"
    )
    (action_tile "area1"
    "(setq area1_var $value)
    (if (and (= button_var \"1\") area1_var area2_var area3_var)(mode_tile \"accept\" 0))"
    )
    (action_tile "area2"
    "(setq area2_var $value)
    (if (and (= button_var \"1\") area1_var area2_var area3_var)(mode_tile \"accept\" 0))"
    )
    (action_tile "area3"
    "(setq area3_var $value)
    (if (and (= button_var \"1\") area1_var area2_var area3_var)(mode_tile \"accept\" 0))"
    )
     
    dblaha, Jul 20, 2004
    #3
  4. T.Willey

    T.Willey Guest

    (action_tile "rev-new"
    "(if (= $value 0)
    (mode_tile "accept" 0)
    (if
    (and (/= (get_tile "rev-date") "") (/= (get_tile "rev-des") "") (/= (get_tile "rev-db") ""))
    (mode_tile "accept" 0)
    )
    )"
    )

    I was trying out one condition, but I can't get it to work.

    Here is what I was thinking. If the rev-new toggle was unchecked then the "accept" button would be un-grey, but if they un-checked it then re-checked it then it would test to see if all the other boxes were filled in, and if they were then the "accept" button would be un-greyed.

    If this is not possible, then is there anyother way I could do it? The reason why I was trying to do it this way is because I assign default value to two of the three edit_boxes, so at the start of the dialog box there are not nil.

    I tried it with (mode_tile \"accept\" 0) and it still didnt' work, this is just my last attempt at it without the (\) to see if it would work. I tested the (if statements and they seem to work, but I don't think the (action_tile like it. The error is "; error: too many arguments".

    Thanks for the help and patience.
    Tim
     
    T.Willey, Jul 20, 2004
    #4
  5. T.Willey

    T.Willey Guest

    (action_tile "rev-new"
    "(progn
    (cond
    ((and (= $value \"1\") (/= (get_tile \"rev-des\") \"\") (/= (get_tile \"rev-db\") \"\") (/= (get_tile \"rev-date\") \"\"))
    (mode_tile \"accept\" 0)
    )
    ((= $value \"0\")
    (mode_tile \"accept\" 0)
    )
    ((= $value \"1\")
    (mode_tile \"accept\" 1)
    )
    )
    )"
    )

    This seems to work for my toggle check, but I can't figure out how to do the check for my edit_box.

    Any help is appreciated.
    Tim
     
    T.Willey, Jul 20, 2004
    #5
  6. T.Willey

    T.Willey Guest

    How can I tell when someone starts typing in the edit_box? As soon as they start typing, and it equals something, I want to be able to check that and the other boxes to make sure there is a value in the edit_box. If all the value are not nil, then the ok button will be un-grey.

    I saw the section in help about callback reasons with edit_boxes, but that only fires once you leave the edit_box. I want to be able to exit out of the dialog box when I hit enter in the edit_box if all other boxes are filled, I have it set up now so that you can hit enter in the description edit_box and exit the dialog. Is that possible?

    Thanks,
    Tim
     
    T.Willey, Jul 20, 2004
    #6
  7. T.Willey

    dblaha Guest

    Try this:

    (action_tile "rev-new" "(if (= $value \"0\")(mode_tile \"accept\" 0))
    (if (and (/= (get_tile \"rev-date\") \"\")
    (/= (get_tile \"rev-des\") \"\")
    (/= (get_tile \"rev-db\") \"\")
    )
    (mode_tile \"accept\" 0)
    )
    )"
    )
     
    dblaha, Jul 21, 2004
    #7
  8. T.Willey

    dblaha Guest

    I don't know of any way to get AutoCAD to respond to an edit box until it is exited. However, I don't believe this is necessary for what you are describing.

    The (untested) code I've pasted below will check the condition of the toggle and each edit_box whenever one of them is used. If the toggle is on and all of the edit boxes contain something, the OK button will be available. Otherwise it will be grayed out. In addition, if you hit enter while in any edit_box AND all three edit boxes contain something AND the toggle is on, the focus will shift to the OK button. What this means is that when these criteria are met, you can leave an edit box by hitting enter and then hitting enter again will immediately close the dialog.


    (action_tile "rev-new"
    "(if (and (= $value \"1\")
    (/= (get_tile \"rev-des\") \"\")
    (/= (get_tile \"rev-db\") \"\")
    (/= (get_tile \"rev-date\") \"\")
    )
    (mode_tile \"accept\" 0)
    (mode_tile \"accept\" 1)
    )")
    (action_tile "rev-des"
    "(if (and (/= $value \"\")
    (/= (get_tile \"rev-new\") \"1\")
    (/= (get_tile \"rev-db\") \"\")
    (/= (get_tile \"rev-date\") \"\")
    )
    (progn (mode_tile \"accept\" 0)(mode_tile \"accept\" 2))
    (mode_tile \"accept\" 1)
    )")
    (action_tile "rev-db"
    "(if (and (/= $value \"\")
    (/= (get_tile \"rev-new\") \"1\")
    (/= (get_tile \"rev-des\") \"\")
    (/= (get_tile \"rev-date\") \"\")
    )
    (progn (mode_tile \"accept\" 0)(mode_tile \"accept\" 2))
    (mode_tile \"accept\" 1)
    )")
    (action_tile "rev-date"
    "(if (and (/= $value \"\")
    (/= (get_tile \"rev-new\") \"1\")
    (/= (get_tile \"rev-des\") \"\")
    (/= (get_tile \"rev-db\") \"\")
    )
    (progn (mode_tile \"accept\" 0)(mode_tile \"accept\" 2))
    (mode_tile \"accept\" 1)
    )")
    (action_tile "accept" "(setq rev-des (get_tile \"rev-des\"))
    (setq rev-db (get_tile \"rev-db\"))
    (setq rev-date (get_tile \"rev-date\"))
    (done_dialog)"
    )
     
    dblaha, Jul 21, 2004
    #8
  9. T.Willey

    dblaha Guest

    On second thought, here are the action_tiles but a little tighter this time:

    (action_tile "rev-new" "(checkit)")
    (action_tile "rev-des" "(checkit)")
    (action_tile "rev-db" "(checkit)")
    (action_tile "rev-date" "(checkit)")
    (action_tile "accept" "(setq rev-des (get_tile \"rev-des\"))
    (setq rev-db (get_tile \"rev-db\"))
    (setq rev-date (get_tile \"rev-date\"))
    (done_dialog)"
    )

    (defun checkit ()
    (if (and (= (get_tile "rev-new") "1")
    (= (get_tile "rev-des") "")
    (= (get_tile "rev-db") "")
    (= (get_tile "rev-date") "")
    )
    (progn
    (mode_tile "accept" 0)
    (mode_tile "accept" 2)
    )
    (mode_tile "accept" 1)
    )
    )
     
    dblaha, Jul 21, 2004
    #9
  10. T.Willey

    T.Willey Guest

    dblaha,
    This one seems to work, but if I don't enter anything in the rev-des edit_box and hit enter it still kicks me out and add a new rev (on the first try per drawing). On the next try (hitting enter with nothing in the rev-des edit_box) it kicks me out of the dialot and I get and error "Error: bad argument type: stringp nil". It looks to me like it should not let me leave the dialog if rev-des edit_box is empty, but it does.

    Any idea why this is happening? I'm not that good at coding dialog boxes (as if you couldn't tell).

    Thanks for all the help.
    Tim
     
    T.Willey, Jul 21, 2004
    #10
  11. T.Willey

    dblaha Guest

    I messed up the operators in the checkit routine. Try this:

    (action_tile "rev-new" "(checkit)")
    (action_tile "rev-des" "(checkit)")
    (action_tile "rev-db" "(checkit)")
    (action_tile "rev-date" "(checkit)")
    (action_tile "accept" "(setq rev-des (get_tile \"rev-des\"))
    (setq rev-db (get_tile \"rev-db\"))
    (setq rev-date (get_tile \"rev-date\"))
    (done_dialog)"
    )

    (defun checkit ()
    (if (and (= (get_tile "rev-new") "1")
    (/= (get_tile "rev-des") "")
    (/= (get_tile "rev-db") "")
    (/= (get_tile "rev-date") "")
    )
    (progn
    (mode_tile "accept" 0)
    (mode_tile "accept" 2)
    )
    (mode_tile "accept" 1)
    )
    )

    Are you setting an initial value in each of the edit boxes or are they empty when you start?
     
    dblaha, Jul 21, 2004
    #11
  12. T.Willey

    T.Willey Guest

    I already tried that, but it still didn't work the way it should. I'm only setting two edit boxes (rev-date, rev-db).

    Tim
     
    T.Willey, Jul 21, 2004
    #12
  13. T.Willey

    dblaha Guest

    It would help if you posted all of your code, including your DCL file, so we can see what you see.
     
    dblaha, Jul 21, 2004
    #13
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.