Author Topic: dcl-TextBox-SetSel looks like it doesn't work  (Read 239 times)

0 Members and 1 Guest are viewing this topic.

domenicomaria

  • Bull Frog
  • Posts: 389
dcl-TextBox-SetSel looks like it doesn't work
« on: June 10, 2022, 04:14:54 AM »
(dcl-TextBox-SetSel dgs-prj dgs-frm "textbox" 0 -1)

dcl-TextBox-SetSel looks like it doesn't work ...

doesn't select text

doesn't select anything !

is there anyone who has experienced the same problem ?

owenwengerd

  • Bull Frog
  • Posts: 448
Re: dcl-TextBox-SetSel looks like it doesn't work
« Reply #1 on: June 10, 2022, 12:33:06 PM »
The string "textbox" is invalid. Perhaps you intended this:
Code - Auto/Visual Lisp: [Select]
  1. (dcl-Control-SetText dgs-prj "textbox")
  2. (dcl-TextBox-SetSel dgs-prj dgs-frm 0 -1)

domenicomaria

  • Bull Frog
  • Posts: 389
Re: dcl-TextBox-SetSel looks like it doesn't work
« Reply #2 on: June 10, 2022, 01:42:20 PM »
dgs-prj is the variabile that contains the name of the odcl project
while
dgs-frm is the variabile that contains the name of the form
and
"textbox" is the name of the textbox control
« Last Edit: June 10, 2022, 01:56:56 PM by domenicomaria »

owenwengerd

  • Bull Frog
  • Posts: 448
Re: dcl-TextBox-SetSel looks like it doesn't work
« Reply #3 on: June 10, 2022, 05:25:42 PM »
Ah, I see, you use strings instead of symbols to refer to the control. In that case, maybe the failure is related to the context in which the function is called. Does it work in a button clicked event?

domenicomaria

  • Bull Frog
  • Posts: 389
Re: dcl-TextBox-SetSel looks like it doesn't work
« Reply #4 on: June 11, 2022, 01:47:32 AM »
It is called at ON-INITIALIZE event

domenicomaria

  • Bull Frog
  • Posts: 389
Re: dcl-TextBox-SetSel looks like it doesn't work
« Reply #5 on: June 11, 2022, 02:15:30 AM »
Code - Auto/Visual Lisp: [Select]
  1. (defun :DCL-GETSTRING (title description default left-top-lst / %dgs-frm %dgs-prj default description r-string title )
  2.  
  3.    (defun c:DCL-GETSTRING-ONINITIALIZE (/)
  4.       (dcl-control-setcaption %dgs-prj %dgs-frm "title"        title       )
  5.       (dcl-control-setcaption %dgs-prj %dgs-frm "description"  description )
  6.       (dcl-control-settext    %dgs-prj %dgs-frm "textbox"      default     )
  7.       (dcl-TextBox-SetSel     %dgs-prj %dgs-frm "textbox"      0        -1 )
  8.       (dcl-Control-SetFocus   %dgs-prj %dgs-frm "textbox")
  9.    )
  10.  
  11.    (defun C:DGS-OK (/)   (setq r-string (dcl-control-gettext    %dgs-prj %dgs-frm "textbox") )   (dcl-form-close %dgs-prj %dgs-frm) )
  12.  
  13.    (defun C:DGS-ONRETURNPRESSED (/)   (setq r-string (dcl-control-gettext    %dgs-prj %dgs-frm "textbox") )   (dcl-form-close %dgs-prj %dgs-frm) )
  14.    
  15.    (defun C:DGS-CANCEL (/)   (setq r-string nil )   (dcl-form-close %dgs-prj %dgs-frm) )
  16.  
  17.    (setq  %dgs-prj "dcl-getstring" %dgs-frm "dcl-getstring-frm")
  18.    (dcl-loadproject %dgs-prj t)
  19.  
  20.    (cond
  21.       (   (and left-top-lst (listp left-top-lst) )
  22.           (dcl-form-show %dgs-prj %dgs-frm (car left-top-lst) (cadr left-top-lst) )
  23.       )
  24.       (   (= left-top-lst T)
  25.           (setq left-top-lst (dcl-getmousecoords)  )
  26.           (dcl-form-show %dgs-prj %dgs-frm (car left-top-lst) (cadr left-top-lst) )
  27.       )
  28.       (T  (dcl-form-show %dgs-prj %dgs-frm ) )
  29.    )
  30.    r-string
  31. )
  32.  
  33. (defun c:k ()
  34.    (setq   mc     (dcl-getmousecoords)   left (nth 0 mc)   top  (nth 1 mc)
  35.          r     (:DCL-GETSTRING "... NEW SUB-MENU NAME ..." " enter the new sub menu name, below :" "[ M E N U  0 1 ]" (list left top) )
  36.    )
  37.    r
  38. )
  39.  
« Last Edit: June 11, 2022, 02:19:40 AM by domenicomaria »

domenicomaria

  • Bull Frog
  • Posts: 389
Re: dcl-TextBox-SetSel looks like it doesn't work
« Reply #6 on: June 11, 2022, 10:26:03 AM »
It depends from the control tab order ...

if I put the textbox control
in the first position,
everything works well !

owenwengerd

  • Bull Frog
  • Posts: 448
Re: dcl-TextBox-SetSel looks like it doesn't work
« Reply #7 on: June 11, 2022, 10:32:36 AM »
I see you discovered a solution while I was composing a reply. Posting anyway in case it is useful in the future.

-- snip --
I suppose your call happens too early, and either gets undone by following initialization by the form itself, or the control just doesn't process selection methods before it is visible. You might try delaying the call by setting a timer and doing it from the timer event; or make this the first control in the form's tab order so the dialog does the work for you when it sets initial focus to the textbox.

domenicomaria

  • Bull Frog
  • Posts: 389
Re: dcl-TextBox-SetSel looks like it doesn't work
« Reply #8 on: June 11, 2022, 10:43:09 AM »
"or make this the first control in the form's tab order"


I think this is the simplest thing ...

thanks for your attention, Owen ...

Ciao