Opened 5 years ago

Closed 5 years ago

#14987 closed defect (fixed)

wxKeyEvent::GetPosition always returning (-1,-1)

Reported by: tm Owned by:
Priority: normal Milestone:
Component: base Version: stable-latest
Keywords: wxKeyEvent Cc:
Blocked By: Blocking:
Patch: yes


Calling wxKeyEvent::GetPosition returns always wxPoint(-1,-1). Using GetX() and GetY() returns the correct mouse position. (wxWidgets from svn, using wxMSW)

How to reproduce: in sample/keyboard/keyboard.cpp, line 489

, event.GetX()
, event.GetY()


, event.GetPosition().x
, event.GetPosition().y

When now running the keyboard example, column position contains always (-1,-1)

Probably introduced in changeset 72207.
Possible solution: wxKeyEvent::GetPosition needs to call InitPositionIfNecessary() before returning values.

Attachments (1)

wxkeyevent_position.patch download (1.6 KB) - added by tm 5 years ago.

Download all attachments as: .zip

Change History (3)

Changed 5 years ago by tm

comment:1 Changed 5 years ago by tm

  • Patch set

Added patch with possible solution for this bug.

comment:2 Changed 5 years ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [73411]) Fix wxKeyEvent::GetPosition() after the changes of r72207.

Now that the position of wxKeyEvent is initialized on demand, don't use m_x
and m_y fields directly but always use GetX() and GetY().

Also improve GetPosition() documentation slightly and mention only the new
version, taking wxCoord, in it as the old one, taking long, is provided for
compatiblity only.

Closes #14987.

Note: See TracTickets for help on using tickets.