OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: Iulian on March 22, 2010, 06:24:16 AM

Title: question about Checkbox
Post by: Iulian on March 22, 2010, 06:24:16 AM
On my modeless form I have a few tools ( Option Lists, Frames, Check Boxes etc.)...
I made this procedure: when the CheckBox1 (cb1) is checked the OptionList1(OL1) appears, and when the CheckBox1 is unchecked the OptionList1 is hidden.

OnInitialize event I have set up the Long Value of the CheckBox1 on zero ( what means UNCHECKED), and (dcl_Control_SetVisible Proj_Form1_OptionList1 NIL), to have hidden the OptionList1, and UNCHECKED the CheckBox1.

Now, when I run my project, CheckBox1 is CHECKED, and OptionList1 VISIBLE, although  these were been set up in ONINITIALIZE event of the form1.

What I have remarked, is that after form1 appears, my CheckBox1 is selected...like in picture below....
After that, I putted another CheckBox  (Checkbox2) on my form1, and after project runs, Checkbox2 was selected (I think because was the last putted on the form..),  and my settings from the ONINITIALIZE event of form1 were OK...After that, I have erased the last CheckBox  (cb2), and CheckBox1 were again checked, how it should not be...

What I should do for overseen the selection, on ONINITIALIZE event? because I think this cause my problem...
Thanks.
Title: Re: question about Checkbox
Post by: owenwengerd on March 22, 2010, 06:50:02 AM
Can you upload a simple form and lisp file that demonstrates the problem?  Which version of OpenDCL are you using?
Title: Re: question about Checkbox
Post by: Iulian on March 23, 2010, 12:40:45 AM
This is a simple example...if CheckBox is first in Z/tab order, goes wrong, and for example if Close button is first, everything is OK.
I`m using  OpenDCL.Studio.ENU.6.0.0.23.msi
Thanks.
Title: Re: question about Checkbox
Post by: owenwengerd on March 23, 2010, 05:07:29 AM
I cannot reproduce the problem in AutoCAD 2010 on Windows 7 x64.  Can you test on another computer to see if the problem is reproducible on more than 1 computer?
Title: Re: question about Checkbox
Post by: Iulian on March 23, 2010, 06:22:50 AM
I run the project on 3 different PC, all with Windows XP x 32, with AutoCAD 2007 and AutoCAD 2005...all with the same  OpenDCL.Studio.ENU.6.0.0.23.msi alpha version.
The same result..
Title: Re: question about Checkbox
Post by: owenwengerd on March 23, 2010, 09:02:00 AM
Hopefully someone else will test your sample and let us know whether they have the same problem.
Title: Re: question about Checkbox
Post by: BazzaCAD on March 23, 2010, 10:13:00 AM
Try removing the t reload option from this line:

(dcl_project_load "example" t)
(dcl_project_load "example")
Title: Re: question about Checkbox
Post by: BazzaCAD on March 23, 2010, 10:23:13 AM
Also, these lines don't look right:

Code (autolisp) Select

(defun c:example_Form1_CheckBox1_OnClicked (Value /)
   (setq cb_value (dcl_Control_GetValue example_Form1_CheckBox1))  ;;;; <---- you don't need this line, use the Value passed in by the OnClick function

 (cond ((= cb_value 0)
((dcl_Control_SetVisible example_Form1_OptionList1 NIL))  ;;; <--- too many ()
       )
   
       ((= cb_value 1)
((dcl_Control_SetVisible example_Form1_OptionList1 T))   ;;; <--- too many ()
       )  
)
)


Try this:
Code (autolisp) Select

(defun c:example_Form1_CheckBox1_OnClicked (Value /)
 (cond
   ((= Value 0)
(dcl_Control_SetVisible example_Form1_OptionList1 NIL)
    )
    ((= Value 1)
(dcl_Control_SetVisible example_Form1_OptionList1 T)
    )
 );_ cond
);_ defun


Title: Re: question about Checkbox
Post by: owenwengerd on March 23, 2010, 10:26:23 AM
Barry, are you able to reproduce the OP's problem?

BTW, this would be my version:
Code (autolisp) Select

(defun c:example_Form1_CheckBox1_OnClicked (Value /)
  (dcl_Control_SetVisible example_Form1_OptionList1 (= Value 1))
);_ defun
Title: Re: question about Checkbox
Post by: BazzaCAD on March 23, 2010, 11:04:10 AM
Quote from: owenwengerd on March 23, 2010, 10:26:23 AM
Barry, are you able to reproduce the OP's problem?

I didn't try it yet, since I'm on Win7 & Acad2010. I can try on an other XP machine wit hAcad2008 & 2010 late....
But since it sounded like an issue with reshowing the form & ONINITIALIZE even I thought it might be the reload flag...
Title: Re: question about Checkbox
Post by: owenwengerd on March 23, 2010, 05:53:29 PM
Since the checkbox state is being set in OnInitialize, the initial value (and hence reloading) shouldn't matter one way or the other.  In any case, I hope you get a chance to test it on both systems.
Title: Re: question about Checkbox
Post by: Iulian on March 24, 2010, 02:21:17 AM
Thank you guys for your interest ... I tried all your alternatives, and the result is the same... the single way to resolve this is to put the checkbox in the bottom of the Z/Tab order list...As long as it works...it`s ok.
Thank you again !
Title: Re: question about Checkbox
Post by: owenwengerd on March 24, 2010, 06:05:12 AM
Quote from: Iulian on March 24, 2010, 02:21:17 AMAs long as it works...it`s ok.

Hopefully we can track down the cause in case there's a bug hidden somewhere.
Title: Re: question about Checkbox
Post by: c2k on May 11, 2010, 08:03:16 AM
I am having similar problems with what seems like the oninitialize not working with check boxes.  Thought I should mention I am using Windows 7 64 bit.
Mine is a modal form.  I have a picture box at the front of the Z order and a few check boxes following.  The first check box seems to ignore my oninitialize code.  And as Iulian stated, if I put a button before the check box in the Z order, the check boxes initialize as expected.  It seems the object before the check box needs to have an event or the work around has no effect as my picture box made no difference.
Title: Re: question about Checkbox
Post by: owenwengerd on May 12, 2010, 12:09:58 AM
Can you upload a simple project that demonstrates the problem?
Title: Re: question about Checkbox
Post by: c2k on May 13, 2010, 07:26:24 AM
I have attached a zip file with an .odcl and a .lsp.

What I find is you have to run it and tick some check boxes, then close it.  And do it all over again. After a few times it starts messing up.  I can't figure out any certain way to make it mess up, it just eventually happens.  Sometimes I can't seem to get it to mess up for a long time.

I did find that if you open the .lsp code in the vlide, and then reload it from there it seems to mess up right away.  I have definitely noticed it more when I am working on the lisp.  Hope that helps in some way.
Title: Re: question about Checkbox
Post by: owenwengerd on May 15, 2010, 08:06:24 AM
In the sample project, your main function loads and shows the dialog before it defines the event handler functions. Try moving your event handler function definitions in front of the code that displays the dialog. Let me know whether that resolves your problem.
Title: Re: question about Checkbox
Post by: c2k on May 17, 2010, 06:40:29 AM
I changed the code as suggested and tried again.  I am still seeing the problem.  First time I ran it I checked box 2, pressed text button 2, & closed the dialog.  Ran it again, and check box 1 was checked.  I attached the revised lisp so you can confirm I did what you wanted.
Title: Re: question about Checkbox
Post by: owenwengerd on May 17, 2010, 09:02:19 AM
I have a theory. Are you starting the command by typing it, then pressing the space bar? If so, try it again but press and hold the space bar, then wait to release it until the dialog is completely displayed. Now when you release it, the check box gets checked because it has focus and "space bar up" translates to toggling the check box state. Is that what you're seeing? You can test the theory by using the <Enter> key instead of the space bar when starting the command.
Title: Re: question about Checkbox
Post by: owenwengerd on May 17, 2010, 09:21:02 AM
I've added code to ignore the space bar if it wasn't pressed while the check box control had input focus. This should fix the problem in the next build if I'm correct about the cause.
Title: Re: question about Checkbox
Post by: c2k on May 17, 2010, 10:45:49 AM
You are correct.  Using enter seems to work fine... holding space until the dialog is visible seems to work fine.
I look forward to the next build  ;D Thank you Owen.