Left down not triggering when cursor at far right

I have an app that is displaying pictures in full-screen. I have a left down handler defined as

self.Bind(wx.EVT_LEFT_DOWN, self.evt_left_down)

The handler (with some debug code) is

def evt_left_down(self, event):
    """Enable zoom and redisplay image"""

    _,_,w,h = wx.Display(0).GetGeometry()
    x,y = event.GetPosition()

    print(f'{w=} {x=}')

    if x < 50:
        self.evt_prev(None)
    elif x > w - 50:
        self.evt_next(None)
    else:
        if wx.GetKeyState(wx.WXK_SHIFT):
            self.zoom = ZOOM_FACTOR * 2
        else:
            self.zoom = ZOOM_FACTOR
        
        self.left_down = True
        self.hide_cursor()
        self.Refresh()
        
    event.Skip()

If the cursor is at the far right of the screen, however, nothing happens. The event does not trigger. What do I have to do in order to get the event to trigger in this case? Here is a stripped down version to demonstrate.

import wx

class MyApp(wx.App):
    
    def OnInit(self):
        self.frame = MyFrame(None, -1)
        self.SetTopWindow(self.frame)
        self.frame.Show()
        self.frame.ShowFullScreen(True)
        return True


class MyFrame(wx.Frame):

    def __init__(self, parent, id):
        wx.Frame.__init__(self, parent, wx.ID_ANY)

        self.Bind(wx.EVT_LEFT_DOWN, self.evt_left_down)

    def evt_left_down(self, event):
        _,_,w,h = wx.Display(0).GetGeometry()
        x,y = event.GetPosition()

        print(f'{w=} {x=}')
        event.Skip()
        

if __name__ == "__main__":  
    app = MyApp(0)
    app.MainLoop()

It seems to be working using Python 3.10.12 + wxPython 4.2.1 gtk3 (phoenix) wxWidgets 3.2.2.1 on Linux Mint 21.2

w=1920 x=1919
w=1920 x=1913
w=1920 x=1919
w=1920 x=1919
w=1920 x=1870
w=1920 x=1826
w=1920 x=1302
w=1920 x=997
w=1920 x=712
w=1920 x=408
w=1920 x=0

I’m using

D:>python
Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.

import wx
wx.version()
‘4.2.1 msw (phoenix) wxWidgets 3.2.2.1’

On Windows 11 Home

What happens if you use:

    def evt_left_down(self, event):
        _, _, w, h = wx.Display(0).GetGeometry()
        x, y = self.ClientToScreen(event.GetPosition())

        print(f'{w=} {x=}')
        event.Skip()

Edit: sorry, forget that, you said that the event is not triggering, not that it is giving the wrong values.

I have heard that it’s necessary to have a Panel in the Frame for certain functionality to work correctly on Windows.

I don’t know if that is the case for full-screen mode, but I noticed that the examples given at wxPython: Making your Frame Maximize or Full Screen - Mouse Vs Python do use Panels.

Might be worth a try?

I added a panel and now the event never triggers. Since it works fine without the panel (except for the right margin thingy) I don’t see why adding a panel should be necessary or even desirable. If I move the cursor one pixel to the left it works. I can only assume this is a bug. If it was necessary to add a panel to make the right margin work then it should be necessary to add a panel to make any other position of the cursor work.

That’s odd. I merged your event handler with one of the examples from that webpage I linked and the events did trigger on linux.

import wx

class MyPanel(wx.Panel):
    """"""

    def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent)

        self.Bind(wx.EVT_LEFT_DOWN, self.evt_left_down)
        self.Bind(wx.EVT_KEY_DOWN, self.onKey)


    def evt_left_down(self, event):
        _, _, w, h = wx.Display(0).GetGeometry()
        x, y = self.ClientToScreen(event.GetPosition())

        print(f'{w=} {x=}')
        event.Skip()


    def onKey(self, event):
        """
        Check for ESC key press and exit is ESC is pressed
        """
        key_code = event.GetKeyCode()
        if key_code == wx.WXK_ESCAPE:
            self.GetParent().Close()
        else:
            event.Skip()


class MyFrame(wx.Frame):
    """"""

    def __init__(self):
        """Constructor"""
        wx.Frame.__init__(self, None, title="Test FullScreen")
        panel = MyPanel(self)
        self.ShowFullScreen(True)


if __name__ == "__main__":
    app = wx.App(False)
    frame = MyFrame()
    app.MainLoop()

I tried your code and it works on Windows. I’ll change my code accordingly. Thanks. Still puzzled over my original example though.