Thank you, Mark.

I guess I don't have a choice but to do it this way. (Although it introduces 
some complications).

Many thanks - Helen
  ----- Original Message ----- 
  From: Mark Dootson 
  To: Helen Craigman 
  Sent: Friday, 24 May, 2013 14:18
  Subject: Re: Trying to trigger wxEVT_TREELIST_ITEM_CHECKED programmatically: 
not implemented?


  Hi,

  On 24/05/2013 11:19, Helen Craigman wrote:
  > Hi Mark
  >

  > 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,

  Yes, this particular event is only triggered when the change is caused 
  by the user interface. That is a wxWidgets design decision /feature / 
  bug - depending on your view. The behaviour is documented though.

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

  No. (as noted previously). You can created your own custom events but 
  'mimicking' a built in event is not the way to go. An actual 
  wxTreeListEvent derives from wxNotifyEvent - you would really need to 
  create the event properly.

  >
  > 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).

  true, but this isn't to allow end user usage, rather it it just the way 
  the event 'macro' sub routines are implemented for this particular event.

  >
  > How do you propose I should do it?

  sub handle_item_change {
      my($self, $item) = @_;
      # do stuff with $item;
  }

  sub on_event_item_checked {
      my($self, $event) = @_;
      my $item = $event->GetItem;
      $self->handle_item_change( $item );
  }

  sub set_item_state_by_code {
      my($self, $item, $newstate) = @_;
      $self->{treelist}->CheckItem($item, $newstate);
      $self->handle_item_change( $item );
  }


  Regards

  Mark


Reply via email to