Deleting an item from a scrolledPanel display doesn't always work.

I’ve a function that deletes a selected item from a scrolled panel. As long as I move the mouse to select an item prior to clicking on it - the delete will work. The selected item pops off the display and if there are any additional items they’ll move up to fill the vacancy. However, if I don’t move the mouse after a click and try to delete the new item that appears underneath the mouse pointer nothing happens. I have to move the mouse, even if if it’s only a few pixels in order for the click/delete to work.

def addImageTile(self, evt, fname):

    self.scrollCount += 1

    tile = makeTile(fname, self.scrollPanel, self.scrollCount)

    self.scrollList.append(tile.id)

    tile.Bind(wx.EVT_RIGHT_DOWN,

            lambda evt,

            tmp=(tile.id,tile.GetLabel()):

            self.delete(evt,tmp))

    self.scrollSizer.Add(tile, 0, wx.ALL, .5)

    self.setUpScroll()

    self.bottom(evt)

def delete(self, evt, tmp):

    p = self.scrollList.index(tmp[0])

    self.scrollSizer.Hide(p)

    self.scrollSizer.Remove(p)

    self.scrollCount -= 1

    del self.scrollList[p]

    self.setUpScroll()

def setUpScroll(self):

    self.scrollPanel.SetupScrolling(

        scroll_x=False, scroll_y=True,

        rate_x=0, rate_y=4,

        scrollToTop=False, scrollIntoView=True)
···

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/c19ca414-c0f3-4ae6-b02f-e7b931994ed2%40googlegroups.com.

I’ve seen something like this before. I think Windows needs some mouse motion events in order to know that the mouse has entered the widget’s bounds, and it won’t send click events unless it knows that the cursor is inside the widget. When the widget moves under the pointer, instead of the other way around, it confuses that logic.

Calling self.WarpPointer with an offset of (1,1) from the current position might be enough to trigger the entered state. You can use wx.MouseState to get the current position in screen coordinates, and then self.ScreenToClient to convert that to window coordinates for the call to WarpPointer.

···

On Friday, July 19, 2019 at 2:58:35 PM UTC-7, Mel Tearle wrote:

I’ve a function that deletes a selected item from a scrolled panel. As long as I move the mouse to select an item prior to clicking on it - the delete will work. The selected item pops off the display and if there are any additional items they’ll move up to fill the vacancy. However, if I don’t move the mouse after a click and try to delete the new item that appears underneath the mouse pointer nothing happens. I have to move the mouse, even if if it’s only a few pixels in order for the click/delete to work.

Robin

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/ed69c7fb-2dcf-4451-9a5e-4f27dd3f8ecf%40googlegroups.com.

Hi Robin,

Tried it but it didn’t work. I could see the pointer moving on its own
but it had no effect in letting me click until I actually moved the pointer.

        ms = wx.GetMouseState()
        print(ms.x, ms.y)
        pos = self.ScreenToClient(ms.x, ms.y)
        print(pos[0], pos[1])
        self.WarpPointer(pos[0]-25, pos[1]+25)
        self.WarpPointer(pos[0]-1, pos[1]-1)

Other than using WarpPointer is there any other way to simulate a mouse
pointer move?

Thanks for the help.

Mel

···

On Jul 19, 2019, at 6:15 PM, Robin Dunn <robin@alldunn.com> wrote:

On Friday, July 19, 2019 at 2:58:35 PM UTC-7, Mel Tearle wrote:
I've a function that deletes a selected item from a scrolled panel. As long as I move the mouse to select an item prior to clicking on it - the delete will work. The selected item pops off the display and if there are any additional items they'll move up to fill the vacancy. However, if I don't move the mouse after a click and try to delete the new item that appears underneath the mouse pointer nothing happens. I have to move the mouse, even if if it's only a few pixels in order for the click/delete to work.

I've seen something like this before. I think Windows needs some mouse motion events in order to know that the mouse has entered the widget's bounds, and it won't send click events unless it knows that the cursor is inside the widget. When the widget moves under the pointer, instead of the other way around, it confuses that logic.

Calling self.WarpPointer with an offset of (1,1) from the current position might be enough to trigger the entered state. You can use wx.MouseState to get the current position in screen coordinates, and then self.ScreenToClient to convert that to window coordinates for the call to WarpPointer.

--
Robin

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/ed69c7fb-2dcf-4451-9a5e-4f27dd3f8ecf%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/B907A6C4-280D-4CEB-A657-04878915E78C%40gmail.com.

Hi Robin,

Tried it but it didn’t work. I could see the pointer moving on its own

but it had no effect in letting me click until I actually moved the pointer.

    ms = wx.GetMouseState()
    print(ms.x, ms.y)

    pos = self.ScreenToClient(ms.x, ms.y)

    print(pos[0], pos[1])

    self.WarpPointer(pos[0]-25, pos[1]+25)    

    self.WarpPointer(pos[0]-1, pos[1]-1)

Other than using WarpPointer is there any other way to simulate a mouse

pointer move?

Try wx.UIActionSimulator.MoveMouse. If that doesn’t help then you should also try doing the move (either WarpPointer or MoveMouse) from a function invoked with CallAfter so the moved widgets have a chance to process their own event handlers associate with the move first.

BTW, wx.Point (and similar classes) support + and - operators, so you can do things like this to offset a wx.Point to a new wx.Point object:

pos = wx.Point(12,34)

pos + (1,1)

wx.Point(13, 35)

···

On Friday, July 19, 2019 at 10:31:41 PM UTC-7, Mel Tearle wrote:

Robin

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/9df6113f-e6c0-4b62-86a2-3a58684ce870%40googlegroups.com.

Hi,

I guess I’ll have to live with it for now,

the last changes moved the pointer but didn’t trip the event. I was thinking If there were a way to tell the mouse pointer that it’s left the old window and entered a new one, that might work. Is it possible to do something like that?

Thank you once again.

Mel

Hi Robin,

Tried it but it didn’t work. I could see the pointer moving on its own

but it had no effect in letting me click until I actually moved the pointer.

    ms = wx.GetMouseState()
    print(ms.x, ms.y)

    pos = self.ScreenToClient(ms.x, ms.y)

    print(pos[0], pos[1])

    self.WarpPointer(pos[0]-25, pos[1]+25)    

    self.WarpPointer(pos[0]-1, pos[1]-1)

Other than using WarpPointer is there any other way to simulate a mouse

pointer move?

Try wx.UIActionSimulator.MoveMouse. If that doesn’t help then you should also try doing the move (either WarpPointer or MoveMouse) from a function invoked with CallAfter so the moved widgets have a chance to process their own event handlers associate with the move first.

BTW, wx.Point (and similar classes) support + and - operators, so you can do things like this to offset a wx.Point to a new wx.Point object:

pos = wx.Point(12,34)

pos + (1,1)

wx.Point(13, 35)

···

On Jul 20, 2019, at 11:05 AM, Robin Dunn robin@alldunn.com wrote:
On Friday, July 19, 2019 at 10:31:41 PM UTC-7, Mel Tearle wrote:

Robin

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/9df6113f-e6c0-4b62-86a2-3a58684ce870%40googlegroups.com.


You received this message because you are subscribed to the Google Groups “wxPython-users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/0663943E-2896-4150-A1B7-D09A350B8761%40gmail.com.

Not that I know of.

···

On Saturday, July 20, 2019 at 2:20:33 PM UTC-7, Mel Tearle wrote:

I was thinking If there were a way to tell the mouse pointer that it’s left the old window and entered a new one, that might work. Is it possible to do something like that?

Robin

Discuss wxPython

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/c85bbf39-15cb-42e8-9854-c2dc64b38e3b%40googlegroups.com.