Problem with Tutorial

Started by anishtain4, January 29, 2012, 11:41:45 PM

Previous topic - Next topic

anishtain4

hi,

I'm new in OpenDCL and I love it from the first place, I'm doing the tutorials but there is something I can't figure it out by myself. in Page 8 of tutorials for the level 1 when you have:
Code (autolisp) Select

(defun c:HelloWorld_Form1_TextButton1_OnClicked (/)
  (setq sText (dcl_Control_GetText HelloWorld_Form1_TextBox1))
  (dcl_messagebox (strcat "You Typed: " sText))
  (dcl_Form_Close HelloWorld_Form1)
)

if you click on the text button it works fine, but if you fill in the text box and click enter on keyboard the form just closes without any messagebox. What am I missing?

Fred Tomke

Hello and welcome anishtain4,

in some development languages you can set a dialogresult to a control (like a button). So it is not in OpenDCL, as I remember. There are events like OnOk or OnCancel. You can activate them to catch the events. But I have no experience in that.

For the case the user hits Enter in a focussed TextBox, Grid or ListView I catch OnCancelClose where I get also the hint if the user pressed ESC. If not, I can decide whether the form should be closed (for instance in a form with a single textbox) or not (in forms with a grid in editing state).

I believe the tutorial was made to get into the way using OpenDCL with lisp. Catching Enter will be the next step after working through the tutorial :) .
You will find a sample for that in this FAQ.

Regards, Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

anishtain4

Thanks Fred,

I have two more questions on the intermediate tutorial:

1.in the code below:

Code (autolisp) Select

(defun c:AUBlockTool_PalBlkTool_cmdMInsBlk_OnClicked ( / CSel BlkName X Y Z rot pt)
(setq CSel (dcl_ListBox_GetCurSel AUBlockTool_PalBlkTool_BlockNameList))
(setq BlkName (dcl_ListBox_GetText AUBlockTool_PalBlkTool_BlockNameList CSel))
(setq X (dcl_Control_GetValue AUBlockTool_PalBlkTool_SliderBarXScale))
(setq Y (dcl_Control_GetValue AUBlockTool_PalBlkTool_SliderBarYScale))
(setq Z (dcl_Control_GetValue AUBlockTool_PalBlkTool_SliderBarZScale))
(setq rot (dcl_Control_GetValue AUBlockTool_PalBlkTool_AngleSliderBlkRot))
(setq *blocks* (ssadd))
(while (setq pt (getpoint "Select base point\\Right-click to exit: "))
(command ".insert" BlkName "X" X "Y" Y "Z" Z "R" rot pt)
(ssadd (entlast) *blocks*)
(UpdateSStext)
)
(princ)
)


the values from the sliders should be read, but when I have set up these from the first and there is no other code available for them it reads them zero, I checked the minval property in studio and it is set to 1!! I used a (setq x (max x 1)) to pass this point

2. I for the last slider I have:

Code (autolisp) Select
(defun c:AuBlockTool_PalBlkTool_SliderBarXScale_OnScroll (nValue /)
  (dcl_Control_SetText AUBlockTool_PalBlkTool_TxtScaleX (itoa nValue))
  (DoScale 41 nValue)
  (UpdateLinks (itoa nValue))
  (princ)
)

(defun c:AuBlockTool_PalBlkTool_SliderBarYScale_OnScroll (nValue /)
  (dcl_Control_SetText AUBlockTool_PalBlkTool_txtScaleY (itoa nValue))
  (DoScale 42 nValue)
  (princ)
)

(defun c:AuBlockTool_PalBlkTook_SliderBarZScale_OnScroll (nValue /)
  (dcl_Control_SetText AUBlockTool_PalBlkTool_txtScaleZ (itoa nValue))
  (DoScale 43 nValue)
  (princ)
)


but when I move the Z slider value of x and y change in a linked manner!!! I'm sure name of the scroll I'm sliding is right and there is no (updatelink) in that's event function. I couldn't figure this one out

anishtain4

Got it, I set all the options of x slider then I copied that and changed the name, but the event name was the same, I had to change that one too.