Multiple Graphic Buttons

Started by scottcd, September 09, 2008, 04:19:21 AM

Previous topic - Next topic

scottcd

I am having problems with the following code as it seems to only toggle graphicbutton1.

Is it just me being thick, or is it a bug?

Cheers

Scott

Using version 1.0.0.24
Acad 2006


(defun c:nlc ()

  (dcl_Project_Load "Nortec_Layer_Control" T)
  (dcl_Form_Show Nortec_Layer_Control_Form1)
  (princ)
)

(defun c:Nortec_Layer_Control_Form1_GraphicButton1_OnClicked (/) ; Basement
  (if (= (dcl_Control_GetBackColor Nortec_Layer_Control_Form1_GraphicButton1) -256)
    (progn     ; FREEZE Basement
      (dcl_Control_SetBackColor
Nortec_Layer_Control_Form1_GraphicButton1
855551
      )
      (command "layer" "Freeze" "*basement*" "")
    )
    (progn     ; THAW Basement
      (dcl_Control_SetBackColor
Nortec_Layer_Control_Form1_GraphicButton1
65280
      )
      (command "layer" "thaw" "*basement*" "")
    )
  )
)

(defun c:Nortec_Layer_Control_Form1_GraphicButton2_OnClicked (/) ;Ground
  (if (= (dcl_Control_GetBackColor Nortec_Layer_Control_Form1_GraphicButton2) -256)
    (progn     ; FREEZE Ground
      (dcl_Control_SetBackColor
Nortec_Layer_Control_Form1_GraphicButton2
855551
      )
      (command "layer" "Freeze" "*ground*" "")
    )
    (progn     ; THAW Ground
      (dcl_Control_SetBackColor
Nortec_Layer_Control_Form1_GraphicButton2
65280
      )
      (command "layer" "thaw" "*ground*" "")
    )
  )
)

(defun c:Nortec_Layer_Control_Form1_GraphicButton3_OnClicked (/) ;First
  (if (= (dcl_Control_GetBackColor Nortec_Layer_Control_Form1_GraphicButton3) -256)
    (progn     ; FREEZE First
      (dcl_Control_SetBackColor
Nortec_Layer_Control_Form1_GraphicButton3
855551
      )
      (command "layer" "Freeze" "*First*" "")
    )
    (progn     ; THAW First
      (dcl_Control_SetBackColor
Nortec_Layer_Control_Form1_GraphicButton3
65280
      )
      (command "layer" "thaw" "*First*" "")
    )
  )
)

(defun c:Nortec_Layer_Control_Form1_GraphicButton4_OnClicked (/) ;Second
  (if (= (dcl_Control_GetBackColor Nortec_Layer_Control_Form1_GraphicButton4) -256)
    (progn     ; FREEZE Second
      (dcl_Control_SetBackColor
Nortec_Layer_Control_Form1_GraphicButton4
855551
      )
      (command "layer" "Freeze" "*Second*" "")
    )
    (progn     ; THAW Second
      (dcl_Control_SetBackColor
Nortec_Layer_Control_Form1_GraphicButton4
65280
      )
      (command "layer" "thaw" "*second*" "")
    )
  )
)



scottcd

I think I have sorted it out

I initially created graphicbutton1 and then copied it to create the other buttons.

I deleted the copied buttons and created them manually and it now seems to work.

Not sure if this is a bug or the way it is intended to work?

Cheers

Scott


owenwengerd

Once you enable an event in the events tab, the name of the callback function becomes "fixed".  Copying the button after the event was enabled would have resulted in all buttons calling the same event handler.  You could have manually edited the event handler function name after the copies were made (or just unchecked then rechecked the event, which would have refreshed the event handler function name).

This behavior is a side effect of how event handlers were designed in the original ObjectDCL.
Owen Wengerd (Outside The Box) / ManuSoft

scottcd