OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: copter on June 16, 2009, 03:32:52 AM

Title: OnClicked Event on Block View.
Post by: copter on June 16, 2009, 03:32:52 AM
Hello
In the attached example, the onclicked event is fired on a block view without clicking on the block view.
It seems that selecting an entity before loading the form is "stored" and then, sent as an event.
How can I prevent this behaviour ?
Attached files: Test.lsp - Test.odcl
Thanks
Copter
Title: Re: OnClicked Event on Block View.
Post by: stephan_35 on June 16, 2009, 05:08:48 AM
Hello,

It seems to me it is not possible to access the AutoCAD graphical box with a modal.

You must use a box modless!

In addition, it is preferable to initialize all the controls with the event "oninitialize.

Attached the example running.

working with 5.1.1.6

Best regards
Title: Re: OnClicked Event on Block View.
Post by: copter on June 16, 2009, 07:29:58 AM
Hi Stephan,
I should not want use a modeless form...
I think that is likely a bug: If the clicked point, before loading the form, is out of the area of the next display of the control, it works.
If it is in the area, the onclick event is fired. (I tried with 5.1.1.4.)
Copter
Title: Re: OnClicked Event on Block View.
Post by: Fred Tomke on June 16, 2009, 08:41:26 AM
Hm, quite interesting. Please add a textbutton and make sure that the blockview isn't the first control in the z/tab-order list.
Then this event won't be fired. This also happens to other controls (like textboxes or tab controls) when they are created during show-method.

If such a control is the only control in the form or must be the first in the z/tab-order list then you can avoid it by a variable. I do so with tab controls. But it doesn't work in this case. I would add it as a bug report.

Code (autolisp) Select

(defun c:test (/ isInit)
  (setq el (entsel "Select an entity >"))
  (dcl_project_load "Test" T)
  (setq isInit T)
  (dcl_form_show Test_Form1)
  (princ)
)

(defun c:Test_Form1_OnInitialize (/)
  (setq isInit nil)
)

(defun c:Test_Form1_BlockView1_OnClicked (/)
  (if (not isInit) (dcl_MessageBox "You did click on me !"))
)


Fred
Title: Re: OnClicked Event on Block View.
Post by: copter on June 16, 2009, 09:32:24 AM
Hi Fred

I tried to add a textbutton and others controls without any effect. :(

To Stephan:
You say: "In addition, it is preferable to initialize all the controls with the event "oninitialize."
Could you explain ? Is it preferable for the memory for example ?  Are there any rules for this ?
Because I am working on a big project, I will have to load maybe more than 100 (c:...) call back functions...

Copter
Title: Re: OnClicked Event on Block View.
Post by: stephan_35 on June 16, 2009, 11:59:31 AM
Good evening,

I also work on a big project,
In fact use "OnInitialize" to activate all functions effectively if the dialog was open properly.

Care of all your functions precompiled in a 'fas' file you can save memory, you lose, however, access time (negligible).

It must surely exist some part-specific rules allowing to maximize the memory, unfortunately, I do not know!


Also uses the "OnClose" which will destroy all the functions previously created by making 'nil'


Best regards
Title: Re: OnClicked Event on Block View.
Post by: owenwengerd on June 16, 2009, 08:21:42 PM
Quote from: copter on June 16, 2009, 07:29:58 AM
I think that is likely a bug: If the clicked point, before loading the form, is out of the area of the next display of the control, it works.
If it is in the area, the onclick event is fired. (I tried with 5.1.1.4.)

I'm not sure that this is entirely a bug. The OnClicked event fires when you *release* the mouse button, and in this case, the form is displayed when you *press* the button. This means that the form is open by the time the mouse button is released, which triggers OnClicked. I will investigate to see if there is a workable solution.
Title: Re: OnClicked Event on Block View.
Post by: owenwengerd on June 16, 2009, 09:06:26 PM
This should now be fixed for Beta 7.  I added logic to skip the OnClicked event if the button was not pressed down on the control before it was released.
Title: Re: OnClicked Event on Block View.
Post by: Kerry on June 16, 2009, 11:00:57 PM

thanks Owen, you da bomb !   :)
Title: Re: OnClicked Event on Block View.
Post by: copter on June 16, 2009, 11:18:22 PM
Thanks !
Title: Re: OnClicked Event on Block View.
Post by: velasquez on June 18, 2009, 06:58:05 AM
I have the same problem with a PictureBox in a screen of Splash. 
See in the image that the property Enabled this defined as false. 
But if the user clicks on the image the the form that didn't still appear it recognizes the event of OnClicked.
 
I posted the links for two videos showing this.

http://www.4shared.com/file/112645609/f1fdd41d/Splash-NotClick.html (http://www.4shared.com/file/112645609/f1fdd41d/Splash-NotClick.html)
http://www.4shared.com/file/112647892/177a535d/SplashWithClick.html]
[url]http://www.4shared.com/file/112647892/177a535d/SplashWithClick.html (http://[url)[/url]
Title: Re: OnClicked Event on Block View.
Post by: velasquez on June 18, 2009, 07:01:50 AM
Excuse me. 
It follows the correct link.

http://www.4shared.com/file/112647892/177a535d/SplashWithClick.html (http://www.4shared.com/file/112647892/177a535d/SplashWithClick.html)
Title: Re: OnClicked Event on Block View.
Post by: copter on June 19, 2009, 07:08:04 AM
I also tried the enabled property to false, but the event onclick no more fires.
Copter
Title: Re: OnClicked Event on Block View.
Post by: owenwengerd on July 09, 2009, 10:58:48 AM
Quote from: velasquez on June 18, 2009, 06:58:05 AM
But if the user clicks on the image the the form that didn't still appear it recognizes the event of OnClicked.

Can you post some simple sample code that demonstrates the problem?
Title: Re: OnClicked Event on Block View.
Post by: velasquez on July 09, 2009, 03:23:56 PM
Hello Owen 
This problem this inside of a very big project. 
It is very difficult for me to separate this now. 
As soon as is possible I send for you. 
I made a list of steps below. 
1 - while SplashForm is presented I click with the mouse in the marked area. 
2 - first Form is called and it receives the event of last OnClicked for the splash form. 
3 - the second form is called. 
Below this the code that controls SplashForm.
Code (autolisp) Select

;;;This function controls exhibition of SplashForm
(defun JoyDelaySplash (/ wait)
;;;Wait function
  (defun wait (seconds / stop)
    (setq stop (+ (getvar "DATE") (/ seconds 86400.0)))
    (while (> stop (getvar "DATE")))
  ) ;_ fim de defun   
;;;Show SplashForm
  (dcl_Form_Show DuctilCAD_SplashForm)
;;;Time of wait
  (wait 2)
;;;Close SplashForm
  (dcl_Form_Close DuctilCAD_SplashForm)
;;;
  (setq JoyTagSplash T
JoyNextDlg 1
  ) ;_ fim de setq
  (vl-propagate 'JoyTagSplash)
  (princ)
) ;_ fim de defun
;;; -------------------------------------------------------------------------------------------------------------------
;;;Só executa Inicializacao do quadro Splash se precisar
   (if (not JoyTagSplash)
     (defun c:DuctilCAD_SplashForm_OnInitialize (/)
;;;Centraliza o quadro
       (dcl_Form_Center DuctilCAD_SplashForm)
     ) ;_ fim de defun
   ) ;_ fim de if
;;; -------------------------------------------------------------------------------------------------------------------
;;;LOOP
  (setq JoyNextDlg 1)
;;;While
  (while (/= JoyNextDlg nil)
    (cond
      ((= JoyNextDlg 1)
       (setq JoyNextDlg nil)
       (if (null JoyTagSplash)
(JoyDelaySplash) ;_ SplashForm
;;;FirstForm
(dcl_Form_Show DuctilCAD_DuctilCAD_MainForm)
       ) ;_ fim de if
      )
    ) ;_ fim de cond
  )
Title: Re: OnClicked Event on Block View.
Post by: owenwengerd on July 09, 2009, 03:53:01 PM
You don't show what type of control reports the incorrect OnClicked event.  I created a small test with a picture box, but it works as expected.  I will wait for sample code.