Active cursor instead of focus ?

Started by krunch, August 11, 2009, 05:30:21 AM

Previous topic - Next topic

krunch

Hello everybody

When my dialog box opens I'd want to get the cursor actived in a TextBox, just after the default value (instead of focus wich highlight it)..

Do you think it's possible ??

owenwengerd

Owen Wengerd (Outside The Box) / ManuSoft

krunch

#2
sorry it was for a standart .dcl..

But can you do that with a TextBox, when a Modal Dialog opens ?

owenwengerd

Yes, I believe you can do that with an OpenDCL TextBox by using (dcl_TextBox_SetSel) and a zero-length selection range.
Owen Wengerd (Outside The Box) / ManuSoft

krunch

Thanks, I tried but I didn't find..

Code (autolisp) Select

(defun c:TRY_MBox_OnInitialize (/)
;;;  (dcl_Control_ZOrder TRY_MBox_TextButton1 1)
  (dcl_Control_SetProperty TRY_MBox_TextBox1 "Text" "default")
  (dcl_TextBox_SetSel TRY_MBox_TextBox1 7 7)
)


The content of the TextBox is still highlighted, even with other start/end values for dcl_TextBox_SetSel (like -1), in fact the cursor stays in the end of the TextBox even without dcl_TextBox_SetSel.

And if another control is MovedToTop the TextBox loose the cursor..

owenwengerd

You'll need to do that later in the startup sequence. After OnInitialize returns and the dialog is displayed, input focus is moved to the first control in the tab order, causing any of your attempts in OnInitialize to be ignored.  You might try it from the OnSetFocus event of the text box, or simply change your tab order so the text box is not at the top.
Owen Wengerd (Outside The Box) / ManuSoft

krunch

Ok, it works when dcl_TextBox_SetSel is called by the OnSetFocus event of another control (the first in the tab order). It don't works when called by himself (by the TextBox OnSetFocus).

In fact I added a control because I don't know how to change the tab order...
How do you do ? dcl_Control_SetFocus ?

owenwengerd

You should change the tab order at design time in OpenDCL Studio (see the Tab/Z Order pane):
http://www.opendcl.com/HelpFiles/index.php?page=Usage/Studio.htm
Owen Wengerd (Outside The Box) / ManuSoft

krunch

Yes.. sorry I read too fast and what I was looking for was right under my nose.

Finally, to do what I want, I need a control (must be visible) that support a SetFocus event and that call dcl_TextBox_SetSel ?

May be there is not simpler solution ?

otherwise thank a lot.. nice tool anyway

owenwengerd

I don't see any good solution. Perhaps you could put a PictureBox on the form, then call the SetSel from its OnPaint event handler. You would need to set a flag to make sure that SetSel is only called once.
Owen Wengerd (Outside The Box) / ManuSoft

krunch

Yes it works too ! And picture can be not visible with the same background color

Thank you very much