Author Topic: How to trigger a dropdown OnSelChanged event?  (Read 531 times)

A. van Dalen

  • Member
  • *
  • Posts: 1
How to trigger a dropdown OnSelChanged event?
« on: November 13, 2017, 07:04:53 AM »
Beste Member OpenDCL,

Can you help me with my code? Im starting to learn coding lisp/opendcl i have an issue with updating my value of Textbox1. I made a presset for my combobox but didn't work fine. See the code bellow. When the checkbox is checked the dcl-ComboBox-SetCurSel set my preset to the combox it works. The combobox update my textbox also without a probleme. But when thecombobox is preset by checkbox it  doesn't update my textbox?
How can i trigger the OnSelChanged event witout duplicate function dcl-Control-SetText?

Thank you help and time,

Alwin

Code: [Select]
(defun c:HelloWorld/Form1/ComboBox1#OnSelChanged (ItemIndexOrCount Value /)
   (cond
     ((= ItemIndexOrCount 0)
(dcl-Control-SetText HelloWorld/Form1/Textbox1 "test1")
     )
     ((= ItemIndexOrCount 1)
(dcl-Control-SetText HelloWorld/Form1/layername "test2")
     )
)
(defun c:HelloWorld/Form1/chkKeuze1#OnClicked (1/)
(dcl-ComboBox-SetCurSel HelloWorld/Form2/status2 1)
)

roy_043

  • Sr. Member
  • ****
  • Posts: 346
Re: How to trigger a dropdown OnSelChanged event?
« Reply #1 on: November 13, 2017, 12:40:58 PM »
Welcome to the forum.

Sorry to disappoint you but what you want is not possible:
Note that OnSelChanged is triggered only when the selection is changed by user interaction; it is not called when the selection is changed programmatically.

ScottBolton

  • Member
  • *
  • Posts: 29
Re: How to trigger a dropdown OnSelChanged event?
« Reply #2 on: January 17, 2018, 03:27:59 AM »
Alwin,

I solved a similar problem this morning. I have a drop-down ComboBox and I want a TextBox to change as the drop-down changes. This works fine during runtime, but OnInitialize the TextBox is blank. My workaround was to get the Index of the ComboBox then set the TextBox based on the Index of a list. Eh? My ComboBox will contain achternamen and the TextBox will contain the associated voornaam. I have a global variable list like this:

(setq *Names* '(("Bolton" . "Scott") ("Jones" . "Davy") ("Smith" . "Sam")))

If the ComboBox starts on "Jones" then we can determine that this is the Index of "1" (lists start at "0"), therefore the contents of the TextBox could be set using either (cdr (nth 1 *Names*)) or (cdr (assoc "Jones" *Names*)).

Hopefully this helps a little.

mvg,

Scott