Author Topic: Problem with 'OnClicked' event  (Read 4850 times)

0 Members and 1 Guest are viewing this topic.

Guest

  • Guest
Problem with 'OnClicked' event
« on: June 13, 2007, 04:43:15 PM »
For some reason (probably user error on my part) the OnClicked event for a listbox does NOTHING for me.  I'm using version 4.0.1.1.  Is this a "bug" or am I doing something wrong?!?

Below is my code:

Code: [Select]
(DEFUN C:ODCLTEST ( / )
   (vl-load-com)
   (SETQ sVariable "Not set")

   ;; Ensure the OpenDCL.##.ARX is loaded.
   (OR (VL-SYMBOL-VALUE 'ODCL_GETVERSIONEX)
       (AND (SETQ fn (FINDFILE "OpenDCL_ARXLoader.LSP"))
            (LOAD fn (STRCAT "Failed to load :- " fn))
       )
       (ALERT (STRCAT "Failed to load OpenDCL_ARXLoader.LSP"))
       (EXIT)
   )

   ;; Ensure the Project ODC file is loaded.   
   (OR (ODCL_PROJECT_LOAD "ODCLTEST") (EXIT))

    ;; Show the dialog
   (ODCL_FORM_SHOW ODCLTEST_Form1)
   (SetUp)
   (princ)
)

(defun SetUp ( / )
   (Odcl_ListBox_AddString ODCLTEST_Form1_ListBox1 "Item 1")
   (Odcl_ListBox_AddString ODCLTEST_Form1_ListBox1 "Item 2")
   (Odcl_ListBox_AddString ODCLTEST_Form1_ListBox1 "Item 3")
   (Odcl_ListBox_AddString ODCLTEST_Form1_ListBox1 "Item 4")
   (Odcl_ListBox_AddString ODCLTEST_Form1_ListBox1 "Item 5")
)   

(defun c:ODCLTEST_Form1_ListBox1_OnClicked ( /)
   (Odcl_MessageBox "To Do: code must be added to event handler\r\nc:ODCLTEST_Form1_ListBox1_OnClicked" "To do")
)

Guest

  • Guest
Re: Problem with 'OnClicked' event
« Reply #1 on: June 13, 2007, 04:54:57 PM »
It appears I should be using 'OnSelChanged' instead.  So what's the difference between the two??

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Problem with 'OnClicked' event
« Reply #2 on: June 13, 2007, 05:35:58 PM »
  I'm using version 4.0.1.1.  .................

Is this a typo ?
The corrent build is Beta 16  ( 4.0.1.16 )

Event Clicked 
Indicates that the user has clicked the left mouse button on the control. 
Parameters: none

Event SelChanged 
Indicates that the selection has been changed.
Paramaters: nSelection sSelTex

I don't have time to test the Event Clicked on a ListBox at the moment, but I'll have a look later today. If you have a sample that demonstrated the problem can you post it as a bug at SourceForge.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Problem with 'OnClicked' event
« Reply #3 on: June 13, 2007, 05:44:39 PM »
Looks to me like your setup is a little out of sequence.

    ;; Show the dialog
   (ODCL_FORM_SHOW ODCLTEST_Form1)
   (SetUp)  << this should be in an Form Initialize Event

Once the form is shown ODCL Event trapping takes over so subsequent code is not accessable untill the form is closed.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Problem with 'OnClicked' event
« Reply #4 on: June 13, 2007, 06:00:30 PM »
You're correct, the OnClicked does not fire. I'll report it ...
added : done https://sourceforge.net/tracker/index.php?func=detail&aid=1736781&group_id=187950&atid=923363

This was the code I tried ..
Code: [Select]
(DEFUN C:ODCLTEST (/)
    (VL-LOAD-COM)
    (SETQ sVariable "Not set")
    ;; Ensure the OpenDCL.##.ARX is loaded.
    (OR (VL-SYMBOL-VALUE 'ODCL_GETVERSIONEX)
        (AND (SETQ fn (FINDFILE "OpenDCL_ARXLoader.LSP"))
             (LOAD fn (STRCAT "Failed to load :- " fn))
        )
        (ALERT (STRCAT "Failed to load OpenDCL_ARXLoader.LSP"))
        (EXIT)
    )
    ;; Ensure the Project ODC file is loaded.
    ;; (ODCL_PROJECT_LOAD "ODCLTEST" T)  ;; to force load the ODC file after mods [kwb]
    (OR (ODCL_PROJECT_LOAD "ODCLTEST") (EXIT))
    ;; Show the dialog
    (ODCL_FORM_SHOW ODCLTEST_Form1)
    (PRINC)
)

(DEFUN c:ODCLTEST_Form1_ListBox1_OnSelChanged (nSelection sSelText /)
    (ODCL_MESSAGEBOX
        "To Do: code must be added to event handler\r\nc:ODCLTEST_Form1_ListBox1_OnSelChanged"
        "To do"
    )
)
(DEFUN c:ODCLTEST_Form1_ListBox1_OnClicked (/)
    (ODCL_MESSAGEBOX
        "To Do: code must be added to event handler\r\nc:ODCLTEST_Form1_ListBox1_OnClicked"
        "To do"
    )
)
(DEFUN c:ODCLTEST_Form1_ListBox1_OnRightClick (/)
    (ODCL_MESSAGEBOX
        "To Do: code must be added to event handler\r\nc:ODCLTEST_Form1_ListBox1_OnRightClick"
        "To do"
    )
)

(DEFUN c:ODCLTEST_Form1_OnInitialize (/)
    (ODCL_LISTBOX_ADDSTRING ODCLTEST_Form1_ListBox1 "Item 1")
    (ODCL_LISTBOX_ADDSTRING ODCLTEST_Form1_ListBox1 "Item 2")
    (ODCL_LISTBOX_ADDSTRING ODCLTEST_Form1_ListBox1 "Item 3")
    (ODCL_LISTBOX_ADDSTRING ODCLTEST_Form1_ListBox1 "Item 4")
    (ODCL_LISTBOX_ADDSTRING ODCLTEST_Form1_ListBox1 "Item 5")
)
« Last Edit: June 13, 2007, 06:05:54 PM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Guest

  • Guest
Re: Problem with 'OnClicked' event
« Reply #5 on: June 14, 2007, 08:30:57 AM »
  I'm using version 4.0.1.1.  .................
Is this a typo ?
The corrent build is Beta 16  ( 4.0.1.16 )

That should've been 4.0.1.11

I just downloaded .16 last night.  I'll have to take a look at it.


Thanks for the 'Form Initialize Event' tip.