Opened 5 years ago

Closed 5 years ago

#15350 closed defect (fixed)

wxHtmlWindow does not show link cursor for link area in image map

Reported by: LukasK Owned by:
Priority: normal Milestone:
Component: wxHtml Version:
Keywords: Cc:
Blocked By: Blocking:
Patch: yes


The link cursor is not shown when a link area in an image map is hovered in a wxHtmlWindow, instead the regular arrow pointer is shown, making the links unlikely to be noticed.

Attachments (1)

imagemap-cursor.patch download (2.9 KB) - added by LukasK 5 years ago.
Patch makes the link cursor appear when hovering area in image map.

Download all attachments as: .zip

Change History (4)

Changed 5 years ago by LukasK

Patch makes the link cursor appear when hovering area in image map.

comment:1 Changed 5 years ago by LukasK

I attached a patch which solves this for me and seems to work fine, but this probably needs some review.

The patch introduces wxHtmlCell::GetMouseCursorRelative(wxHtmlWindowInterface*, const wxPoint& pos). The wxPoint is used to determine if the pointer is in a link area in an image map. GetMouseCursorRelative uses GetLink(pos.x, pos.y), where the old function GetMouseCursor merely did GetLink(), i.e. GetLink(0,0).

I used the name GetMouseCursorRelative instead of overloading GetMouseCursor to avoid name hiding in classes deriving wxHtmlCell::GetMouseCursor(wxHtmlWindowInterface*), per Visual Studio warning.

I also added a check if a proper cursor is returned from the old GetMouseCursor (patch lines 25-35 and 44) in the same vein as the existing check for GetCursor. I think it would be nicer to avoid that if possible (it's currently required for wxHtmlWordCell which overrides GetMouseCursor, but may also be required for overrides in user code).

For htmlwin.cpp, I call GetMouseCursorRelative instead of GetMouseCursor, and I also added cursor setting when moving the mouse within a cell, to handle entering/leaving an area in an image map.

Im not certain about relative/absolute positions, the (unchanged) call to GetLink in wxHtmlWindow::HandleIdle attempts to convert to a relative position, but the new call to GetMouseCursorRelative required the unchanged position to work, which suggests the position is relative to the cell already. Some conversion is done in OnInternalIdle before calling HandleIdle.

comment:2 Changed 5 years ago by vadz

  • Status changed from new to confirmed

I'm not sure about the positions neither but your code seems correct to me and the patch seems to work for the image map in the html/test sample, so I'm going to apply it.

Just one thing: please think to update the documentation for any new public methods you add, please see the changes to interface/wx/html/htmlcell.h for how I did it. TIA!

comment:3 Changed 5 years ago by VZ

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

(In [74570]) Set mouse cursor correctly over image map links in wxHTML.

The cursor didn't change to a link one when the mouse was over link areas in
an image map.

Fix this by generalizing wxHtmlCell::GetMouseCursor() into GetMouseCursorAt().

Closes #15350.

Note: See TracTickets for help on using tickets.