[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] Code review: product editor

From: Greg Chicares
Subject: Re: [lmi] Code review: product editor
Date: Thu, 29 Mar 2007 12:09:27 +0000
User-agent: Thunderbird (Windows/20060516)

On 2007-3-21 23:38 UTC, Vadim Zeitlin wrote:
> On Thu, 22 Mar 2007 00:31:06 +0100 Evgeniy Tarassov <address@hidden> wrote:
> ET> I'd expect an EVT_TREE_SEL_CHANGED event to be generated,
> ET> but from WX docs:
> ET>   wxTreeItemId GetItem() const
> ET>   Returns the item (valid for all events).
> ET> Such an event could only return the root node id.
>  This is a misunderstanding, "valid for all events" doesn't mean that the
> returned wxTreeItemId is always valid (it is not) but just that it is legal
> to call GetItem() from any tree event handler, unlike, say, GetKeyCode()
> method of the same class which can only be called from TREE_KEY_DOWN event
> handler.

Here's the way we're thinking of handling this situation,
in an EVT_TREE_SEL_CHANGED handler:

    wxTreeCtrl& tree = GetTreeCtrl();

    wxTreeItemId item_id = event.GetItem();
        item_id = tree.GetRootItem(); // QUESTION
    LMI_ASSERT( item_id.IsOk() );

I accept that we can arrive at the line marked "QUESTION"
(though I'm not sure how). But what I'd really like to ask
is exactly what benefit that line has, when it is reached.

Suppose that event.GetItem().IsOk() returns false. Then can
GetTreeCtrl().GetRootItem().IsOk() return true? If so, then
why doesn't event.GetItem() just figure that out and return
the root item? I mean, if the purpose of event.GetItem() is
to tell us which item has gained the selection, and the root
has the selection, then why wouldn't GetItem() return the

Or have I assumed too much? When the "QUESTION" line is
reached, is GetTreeCtrl().GetRootItem().IsSelected()
necessarily true? If not, then what is the benefit of
proceeding as though the root were selected when it's not?

But in the case (mentioned earlier in this thread) where a
treectrl's root has been removed under program control, I
guess no reasonable workaround can be imagined: there just
aren't any items, right? Yet in that case the line marked
"QUESTION" can't help, can it? In what case would it help?

Suppose a selected non-root item is removed under program
control. Then doesn't some other item gain the selection?
I'm pretty sure that's the way the msw native control works
(I checked it using ms "control spy"), though of course
other platforms might behave differently.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]