Hi Mark

In the OP, I have posted just a code snippet, in order not to burden the forum.

In my code, I do use the CheckItem method, and that's working fine.
The issue is, after I change the item check state, the event handler
for EVT_TREELIST_ITEM_CHECKED does not get
triggered, since the change did not originate from a widget.
I need to have the event handler invoked in order to take care of
the state change implications.

Studing the documentation, I undestood that the way to
have the event handler invoked, is to programatically raise the "command
event" (in this case: EVT_TREELIST_ITEM_CHECKED).

Now an event handler has this in the beginning:
Quote ----------
my( $this, $event ) = @_;
 $item = $event->GetItem;
Unquote -------

So, since  it's looking for an event object, I don't know how to call it,
except for raising EVT_TREELIST_ITEM_CHECKED.
And in order to raise the event programatically, you need
wxEVT_TREELIST_ITEM_CHECKED.

By the way, other command event constants do get exported in wxPerl
(for example wxEVT_COMMAND_CHECKBOX_CLICKED).

How do you propose I should do it?

Many TIA - Helen.

Johan: you are right, of course. It's 5.16.3 with 2.9.4, and not
like I wrote mistakenly in the OP.

when you
----- Original Message ----- From: Mark Dootson
To: wxperl-users@perl.org
Sent: Friday, 24 May, 2013 12:35
Subject: Re: Trying to trigger wxEVT_TREELIST_ITEM_CHECKED programmatically: not implemented?


Hi Helen,

On 24/05/2013 04:43, Helen Craigman wrote:
Hi wxPerl-users
I am using wxPerl with wxWidgets 2.9.5. I am using TreeListCtrl, and need
  to implement triggering EVT_COMMAND_TREELIST_ITEM_CHECKED
  programmatically.

In Wx we don't change state of anything by raising events. To change
state in our code, we call the object methods. To change the checked
state of a wxTreeListItem

use Wx qw( :checkbox );
....

$wxtreelistctrl->CheckItem(
    $wxtreelistitem,
    wxCHK_CHECKED
);

$wxtreelistctrl->CheckItem(
    $wxtreelistitem,
    wxCHK_UNCHECKED
);

---------------------------
For either wxEVT_TREELIST_ITEM_CHECKED or
  wxEVT_COMMAND_TREELIST_ITEM_CHECKED, compilation fails with the error:

------------
"wxEVT_TREELIST_ITEM_CHECKED" is not exported by the Wx module
------------

As noted above, the wxEVT_TREELIST_ITEM_CHECKED constant is not exported
at it has no practical use in user code.

Hope it helps

Mark

Reply via email to