Using $reason with image_button

Discussion in 'AutoCAD' started by Marcel Janmaat, Dec 9, 2004.

  1. Howcome I cannot use $reason with an image button.
    It alway seems to resolve in 1.

    Any ideas?

    M
     
    Marcel Janmaat, Dec 9, 2004
    #1
  2. Marcel Janmaat

    BillZ Guest

    Double click on image will return reason 4.



    Bill
     
    BillZ, Dec 9, 2004
    #2
  3. Not in my case.

    I do not uderstand.

    What i do is this;

    (action_tile "img" "(cond ((= $reason 1) (sin_dbc)) ((= $reason 4)
    (sin_cfg)))")

    And it always uses the result 1 (single or bouble click)

    M
     
    Marcel Janmaat, Dec 9, 2004
    #3
  4. Thanx for the program Bill. Simple but cool.

    I tried translating it to my own code but still kept running in to the same
    problem.

    It has to do with leaving the dialog or calling a new one.

    with reason 1 (single click) I want to call a new dialog over the one thats
    already there.

    and

    With reason 4 (double click) I want to end the dialog and return with the
    obtained value to the rest of my code.

    Somewhat like this;
    (action_tile "img" "(sin_dbc $reason)") ;<- (double)clicking the image

    (defun sin_dbc ( reason / rlp klp)
    (cond
    ((= reason 1) (sin_cfg)) ;<- calls the new dialog over the existing one
    ((= reason 4)
    (sin_pos)
    (setq H_cadsnm (strcat sbd sbt rlp klp))
    (if (null (tblsearch "block" H_cadsnm))
    (progn (set_tile "ts1" (strcat "Vrije positie voor " H_cadsnm))
    (setq H_cadsnm nil rlp nil klp nil)
    )
    (progn (done_dialog 1) (sin_sol))
    )
    ) )
    )

    Any sugs?

    Marcel
     
    Marcel Janmaat, Dec 9, 2004
    #4
  5. Hello Bill,

    Thinking out loud...

    It seems to me like, at first it assumes 1 and then emediatly runs the
    actions beloning to 1 (leaving the dialogbox) when it actualy has to wait to
    determain if it was a single(1) or a double click(4), and the run the
    correct actions accordingly.

    It looks like there has to be some kind of delay or something.

    M
     
    Marcel Janmaat, Dec 9, 2004
    #5
  6. Marcel Janmaat

    BillZ Guest

    Sorry for the delay,

    Reason 1 always preceeds reason 4 (according to the help files).

    I'm testing some thoughts now and will get back.

    Bill
     
    BillZ, Dec 9, 2004
    #6
  7. Marcel Janmaat

    BillZ Guest

    It looks like there has to be some kind of delay or something.
    <<<

    Marcel,

    I think that the probelm is that anything that takes the focus off the image_button like an alert (or even a mode_tile that sets the focus to another tile), keeps the reason 4 from being read.

    Maybe someone else can chime in here with their expertise but I think that if you want to use reason = 4 then reason = 1 would have to be kept for uses specific to the image_button, i.e. highlighting the image or fill_image ect.

    Open another dialog would have to come from a different tile like a button.

    Bill
     
    BillZ, Dec 9, 2004
    #7
  8. Thanx a lot for your input Bill.

    I use this to insert symbols into a drawing. The image I'm clicking displays
    a raster with symbols. What I wanted to do is insert te selected symbol
    (leave the dialogebox) by a single click, and go to the settings for this
    symbol (open a new dialog) by double clicking on it. But unfortunatly this
    cannot be done. It can be done the way around. It all has to with the 1
    before 4 sequence of reason. It works the way around though. But now I
    always have to doubleclick to insert a symbol insted of a single click. Wich
    is too bad, beceause mostly I want to insert the symbol rather than adjust
    it's settings. (to prevent RSI)

    If you have any sugestion there might be another solution on how it can be
    done otherwise, I'm all ears.

    Thanx again.

    M
     
    Marcel Janmaat, Dec 9, 2004
    #8
  9. Marcel Janmaat

    BillZ Guest

    If you have any sugestion there might be another solution on how it can be
    done otherwise, I'm all ears.<<<

    Marcel,
    The only way I can think of that can possibly work in a manner that's consistant with Windows would be a Double click (fast) to open the properties dialog and a Double click (a lot more slowly) to do the insert operation. You can then adjust your double click speed from the control panel.

    Code:
    //  Bill Zondlo  12/10/04
    //  Dialoge Box for test image, MAP (map.lsp)
    //
    //
    dcl_settings : default_dcl_settings
    { audit_level = 3              ;}
    map : dialog {
    label = "Map"                    ;
    :image_button {
    key          = "map"           ;
    height       = 10              ;
    width        = 30	        ;
    aspect_ratio = 0.0             ;
    color        = graphics_background             ;
    alignment    = centered        ;
    is_tab_stop  = false           ;
    }
    :button  {
    key = "cancel"  ;
    is_cancel   =  true  ;
    label  =   "Cancel" ;
    fixed_width = true  ;
    mnemonic  =  "C" ;
    }
    }
    Code:
                        ;12/10/04 BILL ZONDLO
    ;handler for map.dcl
    ;
    ;
    ;-------------------;
    ;-------------------;
    (defun get_click (reason)
    (setq saveclick (cons reason saveclick)
    )
    (cond ((= (length saveclick) 2)
    (setq saveclick (apply '+ saveclick))
    (if (= saveclick 2)
    (progn
    (alert "This leg will insert the symbol.")
    (setq saveclick nil)
    (done_dialog 1)
    )
    (if (= saveclick 5)
    (progn
    (alert "Open another dialog box.")
    (setq saveclick nil)
    )
    ));ifs
    
    )
    )
    )
    ;----------------------------------;
    (defun c:map ( / dcl_id saveclick)
    (setq dcl_id (load_dialog "g:/lsptemp/map.dcl"))
    (if (not (new_dialog "map" dcl_id "" cl))
    (exit)
    )
    (action_tile "map" "(get_click $reason)")
    (action_tile "cancel" "(done_dialog 0)")
    (setq ans (start_dialog)
    )
    (unload_dialog dcl_id)
    (cond ((= ans 1)
    (alert "Do your insert stuff here.")
    )
    )
    )
    Bill
     
    BillZ, Dec 10, 2004
    #9
  10. Thanx Bill,

    I have to singleclick twice now to get to the dialoge with "This leg will
    insert the symbol". It has to be once. Doubleclicking is ok.
    I'm looking into it...

    Marcel

     
    Marcel Janmaat, Dec 10, 2004
    #10
  11. Thanx Gary, but I think I 'm gonna use Bill's previous response.
    I use doubleclick now to insert. I guess I had to get used to it.
    I defined a different button for the so called properties dialog.

    If I'm ever gonna change my mind I'll look into your code.

    M
     
    Marcel Janmaat, Dec 10, 2004
    #11
  12. Marcel Janmaat

    GaryDF Guest

    I know this is changing the subject........this is what comes to mind when you
    say
    doubleclick.

    C:LISO is my layer isolate routine.
    C:DIM-ALL is my dim home and update routine.

    James Buzbee has an excellent routine, that I have just starting using.
    I added to it.... Give it a try.

    Gary

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Double Click Reactor
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;

    ;;;
    ;;; James Buzbee's Double Click Reactor
    ;;;

    (vl-load-com)

    ;;; 2000i 2002 and 2004
    ;;; This is the main callback function where you'll define
    ;;; what command is fired over what object - see the command list
    ;;; If multiple objects are gripped and the command does not support
    ;;; multiple editing you will be prompted for an entity to edit.
    ;;;

    (defun jb:beginDoubleClick (reactorObject Listofsomething / point obj owner
    ownerobj
    command-list cmd gripset)
    ;;; added for error in 2004 - point returned from outside a
    ;;; paperspace viewport throws an error.
    (if (vl-catch-all-error-p
    (vl-catch-all-apply 'trans (list (car Listofsomething) 0 1)))
    (princ "PaperSpace")
    (progn
    (setq cmd "_.PROPERTIES" ; command default
    point Listofsomething
    obj (car (nentselp (trans (car point) 0 1)))
    owner (car (cadddr (nentselp (trans (car point) 0 1))))
    gripset (cadr (ssgetfirst))
    doc (vlax-get (vlax-get-acad-object) "activedocument"))
    (if obj
    (progn ; this statement will determine if the object
    ; clicked over is an insert or not
    (cond (owner
    (setq ownerobj
    (strcase (vlax-get (vlax-ename->vla-object owner)
    "objectname"))))
    (t
    (setq ownerobj
    (strcase (vlax-get (vlax-ename->vla-object obj)
    "objectname")))))
    ;;Now set up your commands for the appropriate object
    ;; Object Command
    ;;(cons "ACDBBLOCKREFERENCE" "_.REFEDIT ")
    (setq command-list
    (list (cons "ACDBBLOCKREFERENCE" "_.REFEDIT")
    (cons "ACDBATTRIBUTE" "_.EATTEDIT")
    (cons "ACDBMTEXT" "_.DDEDIT")
    (cons "ACDBTEXT" "_.DDEDIT")
    (cons "ACDBROTATEDDIMENSION" "_.DIM-ALL") ;is my dim home
    and update routine.
    (cons "ACDBALIGNEDDIMENSION" "_.DIM-ALL")
    (cons "ACDBORDINATEDIMENSION" "_.DIM-ALL")
    (cons "ACDBDIAMETRICDIMENSION" "_.DIM-ALL")
    (cons "ACDBRADIALDIMENSION" "_.DIM-ALL")
    (cons "ACDB2LINEANGULARDIMENSION" "_.DIM-ALL")
    (cons "ACDBLEADER" "_.LISO") ;is my layer isolate routine
    (cons "ACDBMLINE" "_.MLEDIT")
    (cons "ACDBPOLYLINE" "_.LISO")
    (cons "ACDBLINE" "_.LISO")
    (cons "ACDBCIRCLE" "_.LISO")
    (cons "ACDBSPLINE" "_.LISO")
    (cons "ACDBPOINT" "_.LISO")
    (cons "ACDBATTRIBUTEDEFINITION" "_.DDEDIT")
    (cons "ACDBHATCH" "_.HATCHEDIT")
    (cons "ACDBRASTERIMAGE" "_.IMAGEADJUST")
    ;;; architectural desktop commands
    (cons "AECDBWALL" "_.PROPERTIES")
    (cons "AECDBDOOR" "_.PROPERTYDATAEDIT")
    (cons "AECDBWINDOW" "_.PROPERTIES")
    (cons "AECDBWINDOWASSEMBLY" "_.PROPERTIES")
    (cons "AECDBCURTAINWALLLAYOUT" "_.PROPERTIES")
    (cons "AECDBSPACE" "_.PROPERTYDATAEDIT")
    (cons "AECDBSTAIR" "_.PROPERTIES")
    (cons "AECDBRAILING" "_.PROPERTIES")
    (cons "AECDBMVBLOCKREF" "_.PROPERTIES")
    (cons "AECDBOPENING" "_.PROPERTIES")
    (cons "AECDBCEILINGGRID" "_.PROPERTIES")
    (cons "AECDBCOLUMNGRID" "_.PROPERTIES")
    (cons "AECDBSLAB" "_.PROPERTIES")
    (cons "AECSDBMEMBER" "_.PROPERTIES")
    (cons "AECDBMASSELEM" "_.PROPERTIES")
    (cons "AECDBROOF" "_.PROPERTIES")
    (cons "AECDBROOFSLAB" "_.PROPERTIES")
    (cons "AECDBCAMERA" "_.PROPERTIES")
    (cons "AECDBSCHEDULETABLE" "_.PROPERTIES")))
    ;;; get the command
    (foreach
    x command-list
    (if (= (car x) ownerobj)
    (setq cmd (cdr x))))
    ;;; make adjustment to command
    (cond ((= cmd "_.REFEDIT")
    (setq cmd "_.refedit (princ (cdr (nentselp (trans(car point)0
    1)))) "))
    ((= cmd "_.ATTEDIT") (setq cmd "_.attedit (princ obj) "))
    ((= cmd "_.EATTEDIT") (setq cmd "_.eattedit (princ obj) "))
    (t (setq cmd (strcat cmd " "))))
    (vla-sendcommand doc cmd))))))

    ;;;
    (defun jb:LoadDoublClickReactor (/)
    (if (/= (type jbDoubleClickReactor) 'VLR-Mouse-Reactor)
    (setq jbDoubleClickReactor
    (VLR-Mouse-Reactor
    nil
    '(:)VLR-beginDoubleClick . jb:beginDoubleClick))) ;_ end of
    vlr-editor-reactor
    ))
    (if (not (vlr-added-p jbDoubleClickReactor))
    (vlr-add jbDoubleClickReactor))
    ;;; Unload acdblclkedit.arx in favor of jb's Expanded Double Click editing!
    (if (member "acdblclkedit.arx" (arx))
    (arxunload "acdblclkedit.arx" nil))
    (princ))
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;
    (progn (jb:LoadDoublClickReactor) (princ))
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;
    (princ)
     
    GaryDF, Dec 10, 2004
    #12
  13. Bill,

    Regarding your first map routine, I was wondering if it also might be
    posible to draw square borders insead of square dots like you did? And then
    clear them every time i give a new click.
    I think you see where I getting at.

    This way I can draw a square around the symbol I'm selecting. A sort of
    highlight.

    MJ


     
    Marcel Janmaat, Dec 11, 2004
    #13
  14. Marcel Janmaat

    BillZ Guest

    This way I can draw a square around the symbol I'm selecting. A sort of
    highlight.<<<

    Marcel,
    (mode_tile "map" 4) is used to toggle the "highlight" for image tiles.

    If you want to draw on the tiles use vector_image.

    Code:
                        ;12/14/04 BILL ZONDLO
    ;handler for map.dcl
    ;
    ;
    ;-------------------;
    (load "g:/autolisp/autolisp/subr/timer")
    ;-------------------;
    (defun get_click (reason)
    (cond ((= cnt 0)
    (start_image "map")
    ;need to do your slide image here too.
    (fill_image 1 1 (- Xcoord 2)(- Ycoord 2) -15)
    (vector_image 1 1 (- Xcoord 2) 1 0)  ;you may need to adjust the numbers according to your resolution.
    
    (vector_image (- Xcoord 2) 1 (- Xcoord 2)(- Ycoord 2) 0)
    (vector_image 1 1 1 (- Ycoord 2) 0)
    (vector_image 1 (- Ycoord 2)(- Xcoord 2)(- Ycoord 2) 0)
    (end_image)
    (setq cnt 1)
    )
    ((= cnt 1)
    (start_image "map")
    (fill_image 0 0 Xcoord Ycoord -15)
    ;need to do your slide image here too.
    (end_image)
    (setq cnt 0)
    )
    )
    )
    ;----------------------------------;
    (defun c:map ( / dcl_id saveclick)
    (setq dcl_id (load_dialog "g:/lsptemp/map.dcl"))
    (if (not (new_dialog "map" dcl_id "" cl))
    (exit)
    )
    (setq Xcoord (dimx_tile "map")
    Ycoord (dimy_tile "map")
    cnt 0
    )
    (action_tile "map" "(get_click $reason)")
    (action_tile "cancel" "(done_dialog 0)")
    (setq ans (start_dialog)
    )
    (unload_dialog dcl_id)
    (cond ((= ans 1)
    (alert "Do your insert stuff here.")
    )
    )
    )

    Bill
     
    BillZ, Dec 13, 2004
    #14
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.