CheckListBox selection of an item based on a clickposition

Hi List,

In a Checklistbox, I want to display a popup window when I right click the
item. However, this should only occur if the item is checked. I am trying to
find out if the item is checked by using the HitTestXY. However, it always
returns 10. So probably I am doing something wrong here. I have checked The X
and Y positions and they are correct.

class ProdCheckListbox(wxCheckListBox):
    def __init__(self, parent):
        wxCheckListBox.__init__(self, choices=[],
id=wxID_ONDCONTRACTENCONTRACTPRODUCTEN, name='ContractProducten',
              parent=parent, pos=wxPoint(400, 70), size=wxSize(320, 288),
              style=0)
        EVT_RIGHT_DOWN(self, self.OnRightClick)
        self.parent = parent
         
    def AddPopupMenu(self, popupmnu):
        """
        This routine adds the popupmenu
        """
        self.P_UpMenu = popupmnu

    def OnRightClick(self, event):
        self.x = event.GetX()
        self.y = event.GetY()
        pt = event.GetPosition()
        item = self.HitTestXY(self.x, self.y)
        if self.IsChecked(item):
            self.x = event.GetX()
            self.y = event.GetY()
            self.PopupMenuXY(self.P_UpMenu.popupmnu, self.x, self.y)
            self.curr_tab_id = self.GetClientData(item)[0]

···

#
--
Cheers,

D.J. Kniep
Lindix BV
Tel. 036-5215580

Dick,

not sure whether I'm misunderstanding this, but wouldn't you simply use
the "IsChecked" method to see if an item is checked (rather than
HitTestXY which does something completely different)?

Markus

···

Am Mon, den 29.12.2003 schrieb Dick Kniep um 15:00:

Hi List,

In a Checklistbox, I want to display a popup window when I right click the
item. However, this should only occur if the item is checked. I am trying to
find out if the item is checked by using the HitTestXY. However, it always
returns 10. So probably I am doing something wrong here. I have checked The X
and Y positions and they are correct.

class ProdCheckListbox(wxCheckListBox):
    def __init__(self, parent):
        wxCheckListBox.__init__(self, choices=,
id=wxID_ONDCONTRACTENCONTRACTPRODUCTEN, name='ContractProducten',
              parent=parent, pos=wxPoint(400, 70), size=wxSize(320, 288),
              style=0)
        EVT_RIGHT_DOWN(self, self.OnRightClick)
        self.parent = parent
         
    def AddPopupMenu(self, popupmnu):
        """
        This routine adds the popupmenu
        """
        self.P_UpMenu = popupmnu

    def OnRightClick(self, event):
        self.x = event.GetX()
        self.y = event.GetY()
        pt = event.GetPosition()
        item = self.HitTestXY(self.x, self.y)
        if self.IsChecked(item):
            self.x = event.GetX()
            self.y = event.GetY()
            self.PopupMenuXY(self.P_UpMenu.popupmnu, self.x, self.y)
            self.curr_tab_id = self.GetClientData(item)[0]
#

Okay, never mind, I now read the code and see the problem.

Sorry.

Markus

···

Am Mon, den 29.12.2003 schrieb Markus Meyer um 15:14:

Dick,

not sure whether I'm misunderstanding this, but wouldn't you simply use
the "IsChecked" method to see if an item is checked (rather than
HitTestXY which does something completely different)?

Markus

Am Mon, den 29.12.2003 schrieb Dick Kniep um 15:00:
> Hi List,
>
> In a Checklistbox, I want to display a popup window when I right click the
> item. However, this should only occur if the item is checked. I am trying to
> find out if the item is checked by using the HitTestXY. However, it always
> returns 10. So probably I am doing something wrong here. I have checked The X
> and Y positions and they are correct.
>
> class ProdCheckListbox(wxCheckListBox):
> def __init__(self, parent):
> wxCheckListBox.__init__(self, choices=,
> id=wxID_ONDCONTRACTENCONTRACTPRODUCTEN, name='ContractProducten',
> parent=parent, pos=wxPoint(400, 70), size=wxSize(320, 288),
> style=0)
> EVT_RIGHT_DOWN(self, self.OnRightClick)
> self.parent = parent
>
> def AddPopupMenu(self, popupmnu):
> """
> This routine adds the popupmenu
> """
> self.P_UpMenu = popupmnu
>
> def OnRightClick(self, event):
> self.x = event.GetX()
> self.y = event.GetY()
> pt = event.GetPosition()
> item = self.HitTestXY(self.x, self.y)
> if self.IsChecked(item):
> self.x = event.GetX()
> self.y = event.GetY()
> self.PopupMenuXY(self.P_UpMenu.popupmnu, self.x, self.y)
> self.curr_tab_id = self.GetClientData(item)[0]
> #

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

Dick Kniep wrote:

Hi List,

In a Checklistbox, I want to display a popup window when I right click the item. However, this should only occur if the item is checked. I am trying to find out if the item is checked by using the HitTestXY. However, it always returns 10. So probably I am doing something wrong here. I have checked The X and Y positions and they are correct.

Platform and version?

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Python 2.3.2 GCC 3.2.3
Linux Slackware 9.1
wxPython 2.4.2.4

By the way, using HitTest and event.GetPosition() also always returns 10 as a
result.

···

On Monday 29 December 2003 23:05, Robin Dunn schreef: > Dick Kniep wrote:

> Hi List,
>
> In a Checklistbox, I want to display a popup window when I right click
> the item. However, this should only occur if the item is checked. I am
> trying to find out if the item is checked by using the HitTestXY.
> However, it always returns 10. So probably I am doing something wrong
> here. I have checked The X and Y positions and they are correct.

Platform and version?

--
Cheers,

D.J. Kniep
Lindix BV
Tel. 036-5215580

Dick Kniep wrote:

···

On Monday 29 December 2003 23:05, Robin Dunn schreef: > >>Dick Kniep wrote:

Hi List,

In a Checklistbox, I want to display a popup window when I right click
the item. However, this should only occur if the item is checked. I am
trying to find out if the item is checked by using the HitTestXY.
However, it always returns 10. So probably I am doing something wrong
here. I have checked The X and Y positions and they are correct.

Platform and version?

Python 2.3.2 GCC 3.2.3
Linux Slackware 9.1
wxPython 2.4.2.4

By the way, using HitTest and event.GetPosition() also always returns 10 as a result.

Looks like there is no HitTest in wxGTK's wxCheckListBox and so it is using the one from wxWindow, which is just returning a bitmask of flags. Please enter a feature request asking for HitTest to be added to wxGTK's wxCheckListBox class.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

How do I enter a feature request?

Is there an alternative way to find out at what item I am standing with the
mousepointer? The only way I can think of now is to the GetString and
compare, which is a horrible way to find out....

···

On Tuesday 30 December 2003 01:30, Robin Dunn schreef: > Dick Kniep wrote:

> On Monday 29 December 2003 23:05, Robin Dunn schreef: > >>Dick Kniep wrote:
>>>Hi List,
>>>
>>>In a Checklistbox, I want to display a popup window when I right click
>>>the item. However, this should only occur if the item is checked. I am
>>>trying to find out if the item is checked by using the HitTestXY.
>>>However, it always returns 10. So probably I am doing something wrong
>>>here. I have checked The X and Y positions and they are correct.
>>
>>Platform and version?
>
> Python 2.3.2 GCC 3.2.3
> Linux Slackware 9.1
> wxPython 2.4.2.4
>
> By the way, using HitTest and event.GetPosition() also always returns 10
> as a result.

Looks like there is no HitTest in wxGTK's wxCheckListBox and so it is
using the one from wxWindow, which is just returning a bitmask of flags.
Please enter a feature request asking for HitTest to be added to wxGTK's
wxCheckListBox class.

--
Met vriendelijke groet,

D.J. Kniep
Lindix BV
Tel. 036-5215580

Dick Kniep wrote:

Looks like there is no HitTest in wxGTK's wxCheckListBox and so it is
using the one from wxWindow, which is just returning a bitmask of flags.
Please enter a feature request asking for HitTest to be added to wxGTK's
wxCheckListBox class.

How do I enter a feature request?

Login to SourceForge, go to http://sourceforge.net/tracker/?atid=359863&group_id=9863 and click Submit New.

Is there an alternative way to find out at what item I am standing with the mousepointer?

Not with wxCheckListBox. You could switch to a wxListCtrl in report mode with no header and use images that represent the checked or not checked state.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!