Image Buttons in DCL files

Discussion in 'AutoCAD' started by whitesquirrel44, Mar 15, 2005.

  1. I'm creating a program with a simple dialog box that has a few image buttons on it. I want my box to work like most other boxes (i.e. Point Styles), when you select a button, highlight the button selected and unhighlight the button that was selected. Is there a way to test if a button is highlighted? I know that Mode_Tile function with option 4 switches on and off.
     
    whitesquirrel44, Mar 15, 2005
    #1
  2. whitesquirrel44

    BillZ Guest

    IMO:
    The only way to do this is to have a (mode_tile "button_1" 4) for when the button is selected, and then more (mode_tile "button_1" 4) for any other button or tile that can be selected alternately.

    Bill
     
    BillZ, Mar 15, 2005
    #2
  3. whitesquirrel44

    BillZ Guest

    Let me rephrase that.

    The only way to do this is to have a (mode_tile "button_1" 4) for when the button is selected, and then more (mode_tile "button_1" 4) for any other button that can be highlighted by selecting it.

    That way only one button will be highlighted at one time.

    Bill
     
    BillZ, Mar 15, 2005
    #3
  4. whitesquirrel44

    BillZ Guest

    That still isn't right.

    I know I've done this before.

    I'll get back here when I can check some of my files.

    Bill
     
    BillZ, Mar 15, 2005
    #4
  5. whitesquirrel44

    BillZ Guest

    Sorry
    I was wrong with my previous replies.

    I used image buttons and they automatically show that they are the selected button with a slight "shadow" around the edge.

    I have used highlighting on image buttons before but cannot think right now what it was.

    Must be a sign of old age...

    Bill
     
    BillZ, Mar 15, 2005
    #5
  6. Bill, Thanks for your input. I think I know what you meant. I thought maybe I could start with a default tile and then test each tile in a callback to see if it's value is 1 and then use the mode_tile function to switch it on and off. I'm having a problem using the get_tile function in the action_tile function. Is there a way to determine in a action_tile function, which tile's value switched from 1 to 0 as a result of selecting the new tile?
     
    whitesquirrel44, Mar 15, 2005
    #6
  7. whitesquirrel44

    BillZ Guest

    Yes,

    Try this sample:

    (defun showval (key val)
    (princ "\n")(princ key)(princ " is now: ")(princ val)(princ)
    )

    (defun c:testimage (/ dcl_id)
    (setq DCL_ID (load_dialog "test.dcl"))
    (if (not (new_dialog "test" DCL_ID))
    (exit)
    )

    (action_tile "stimage1" "(showval $key $value)")
    (action_tile "stimage2" "(showval $key $value)")

    (start_dialog)
    (unload_dialog DCL_ID)
    (princ)
    )

    Here's the DCL:

    test : dialog {
    label = "Test Dialog";
    : row {
    : image_button {
    key = "stimage1" ;
    height = 7 ;
    width = 20 ;
    color = 254 ;
    }
    : image_button {
    key = "stimage2" ;
    height = 7 ;
    width = 20 ;
    color = 255 ;
    }
    }
    ok_cancel;
    }

    Bill
     
    BillZ, Mar 15, 2005
    #7
  8. Bill

    It was so easy, I'm ashamed to say how long it took me to realize it. The following code will allow the image buttons to be highlighted when selected and all others to be unhighlighted.

    (setq oldtile nil)
    (setq imgtask
    "(if (/= oldtile nil) (mode_tile oldtile 4))
    (mode_tile $key 4)
    (setq oldtile $key)"
    );setq
    (action_tile "stimage1" (strcat "(progn" imgtask ACTION ")"))

    Replace the word ACTION with whatever you want to do with your program. My program set a layer name and a hatch pattern name for later use. Also with this code, it doesn't matter how many image tiles you have in your dialog box. I hope you read this. You may want to go back and fix up those older programs. Thanks for your help.
     
    whitesquirrel44, Mar 15, 2005
    #8
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.