beeware / toga

A Python native, OS native GUI toolkit.
https://toga.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
4.36k stars 674 forks source link

Text in table cell rendering on top of adjacent cell #700

Closed arichar6 closed 1 year ago

arichar6 commented 5 years ago

Expected Behavior

When a table cell has content longer than the cell width, I expect the text to be "hidden" behind the adjacent column. Preferably there would be an ellipsis character (…) appended to the truncated text to indicate that text is hidden.

Current Behavior

Using the cocoa backend for macOS, the text is rendered on top of the text from the adjacent column.

Screen Shot 2019-05-24 at 4 31 29 PM

Steps to reproduce

  1. git clone most recent toga
  2. cd to the directory for the table_source example
  3. python -m table_source

Your Environment

freakboy3742 commented 5 years ago

Thanks for the report! Confirmed that this behavior is reproducible; it appears to be a bug in the cell renderer not clipping content to the box border.

freakboy3742 commented 4 years ago

This has been significantly improved on by #822; however, I think there's room for more improvement.

The new code truncates text at the word boundary, but Cocoa has builtin support for text being truncated at the character level, and auto-inserting an ellipsis (...) when the text has been truncated - it even allows for automated squeezing of the kerning if slightly tighter spacing between characters will let a word fit. These features are part of NSTextField; I presume they're adaptable to NSTextFieldCell, but I can't say I can point to an obvious page of docs that says so.