Re: Grid component

Karl Knechtel <[email protected]> Mon, 19 May 2008 18:55:05 -0400 (Eastern Daylight Time)
Newsgroups gmane.comp.python.pythoncard
Message-ID <Pine.WNT.4.61.0805191849520.1920@somebody>

On Sun, 18 May 2008, Jason Harthun wrote:

> Hi.  I need some help with the Grid component.
>
>  Here is the code that I'm working with:
>
>    # ...
>    def on_grdDataGrid_selectCell(self, event):
>        self.components.grdDataGrid.EnableEditing(False)
>        event.skip()
>
>    def on_grdDataGrid_keyDown(self, event):
>        self.components.grdDataGrid.EnableEditing(False)
>        event.skip()
>    # ...
>    def on_grdDataGrid_editorHidden(self, event):
>        result = dialog.messageDialog(self, "Are you sure you wish to save the changes?","Save", wx.YES_NO)
>        if not result.accepted:
>            event.Veto()
>            return
>        event.skip()
>
>
>  I would like to allow editing only if the user double clicks in the 
> cell.  After editing a cell and using enter or tab to exit the cell, the 
> dialog associated with the editorHidden event pops up twice.  I only 
> want it to pop up once.  Any help would be appreciated.  Thanks.

IIRC there is a debugger for this, but my guess is that when the new cell 
is entered, it receives one of the cell selection events, while the old 
cell also gets a key down event. Possible solution: check if the editing 
was already disabled before making the EnableEditing call. Possible design 
enhancement: make an editing_enabled property for the grid instead (such 
that the setter only makes the state-change - implicitly triggering the 
event - when the set state is not the existing state).

Karl Knechtel {:>

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/