Responding to splitter events

Splitter windows trigger events of type wx.SplitterEvent. There are four different event types of the splitter window, as listed in table 8.10.

Table 8.10 Event types of the splitter window

Event Type

Description

EVT_SPLITTER_DCLICK

Triggered when the sash is double-clicked. Trapping this event does not block the normal unsplit behavior of this action, unless you call the event Veto() method.

EVT_SPLITTER_SASH_POS_CHANGED

Triggered at the end of a sash change, but before the change is displayed on screen (so you can react to it). This event can also be halted with Veto().

EVT_SPLITTER_SASH_POS_CHANGING

Triggered repeatedly when the sash is being dragged. This event can be halted by using the event Veto() method, in which case the sash position does not change.

EVT_SPLITTER_UNSPLIT

This is triggered after the splitter has unsplit.

The splitter event class is a subclass of wx.CommandEvent. From the splitter event instance, you can get access to information about the current state of the splitter window. For the two events that concern the movement of the sash, call GetSash-Position() to recover the sash position relative to the left or the top, depending on the splitter orientation. In the position changing event, call SetSashPosi-tion(pos), and the XOR tracking line showing the expected position of the sash moves to the new position. In the position changed event, the same method will move the sash itself. For the double-click event, you can get the exact location of the click using the event's GetX() and GetY() methods. For an unsplit event, you can tell which window is going away using the GetWindowBeingRemoved() method.

Was this article helpful?

0 0

Post a comment