Opened 5 years ago

Closed 5 years ago

#14452 closed defect (fixed)

wxSpinCtrl shows the text as asterisks in wxOSX-Cocoa

Reported by: kyuu Owned by:
Priority: normal Milestone:
Component: wxOSX Version: stable-latest
Keywords: wxSpinCtrl wxOSX-Cocoa asterisks Cc:
Blocked By: Blocking:
Patch: no

Description

wxSpinCtrl shows the text as asterisks in wxOSX-Cocoa.

Attachments (1)

wxSpinCtrl-wxOSX-Cocoa.png download (8.6 KB) - added by kyuu 5 years ago.

Download all attachments as: .zip

Change History (16)

Changed 5 years ago by kyuu

comment:1 Changed 5 years ago by kyuu

Tested in wxWidgets revision 71954.

comment:2 follow-up: Changed 5 years ago by vadz

  • Milestone 2.9.5 deleted
  • Status changed from new to infoneeded_new

Can this be seen in the spin page of the widgets sample?

What styles did you use for your wxSpinCtrl? Could you have used wxTE_PASSWORD or another style with the same value accidentally?

comment:3 in reply to: ↑ 2 Changed 5 years ago by kyuu

  • Status changed from infoneeded_new to new

Replying to vadz:

Can this be seen in the spin page of the widgets sample?

What styles did you use for your wxSpinCtrl? Could you have used wxTE_PASSWORD or another style with the same value accidentally?

You are right, the culprit was a style used with the wxSpinCtrl. I used 'wxSP_ARROW_KEYS | wxALIGN_CENTRE'. After removing wxALIGN_CENTRE the asterisks were gone. Apparently wxALIGN_CENTRE has the same value as wxTE_PASSWORD in wxOSX-Cocoa, but a different value in wxGTK and wxMSW, since the wxALIGN_CENTRE only causes the asterisks to be shown on wxOSX-Cocoa.

comment:4 Changed 5 years ago by kyuu

If you need a patch for this, I can create one. But it would basically come down to something like this:

wxSpinCtrl* spinCtrl = new wxSpinCtrl(parent, wxID_ANY, wxT("10"), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS | wxALIGN_CENTRE);

with the important part being 'wxSP_ARROW_KEYS | wxALIGN_CENTRE'.

comment:5 Changed 5 years ago by csomor

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

wxALIGN_CENTER_VERTICAL is having the same value as wxTE_PASSWORD, wxAlignment is not a style type but should be used with sizers

comment:6 follow-up: Changed 5 years ago by csomor

the reason it is not behaving the same is because wxOSX is using a composited generic control, while msw and gtk have native implementations

comment:7 in reply to: ↑ 6 Changed 5 years ago by kyuu

Replying to csomor:

the reason it is not behaving the same is because wxOSX is using a composited generic control, while msw and gtk have native implementations

In this case, please change the documentation: http://docs.wxwidgets.org/trunk/classwx_spin_ctrl.html

comment:8 Changed 5 years ago by csomor

  • Resolution invalid deleted
  • Status changed from closed to reopened

comment:9 Changed 5 years ago by csomor

thanks yes, we have to change that, for the text you can use wxALIGN_CENTER_HORIZONTAL - although I'd personally prefer to write wxTE_CENTER

comment:10 Changed 5 years ago by vadz

  • Resolution set to invalid
  • Status changed from reopened to closed

[Dummy change, just trying to resolve conflict with my own changes]

comment:11 Changed 5 years ago by vadz

  • Resolution invalid deleted
  • Status changed from closed to reopened

This is really unfortunate but wxGTK and wxMSW do support wxALIGN_RIGHT and wxALIGN_CENTRE so I'm afraid we'd have to hack in support for them into wxOSX too.

Arguably, documenting wxTE_RIGHT and wxTE_CENTRE instead of wxALIGN_XXX should also be done independently of this.

But the real problem, I think, is that -- at least from examining the code -- it seems that single line wxTextCtrl doesn't support alignment at all in wxOSX/Cocoa. Looking at Apple docs there is "alignment" in its bindings list but I have no idea how does it work.

P.S. Did I already mention how I hated flags?

comment:12 Changed 5 years ago by csomor

the problem is that wxALIGN_CENTER does not mean only center horizontally but also center vertically, that value collides with TE_PASSWORD, wxALIGN_CENTER_HORIZONTAL is perfectly fine, although IMHO dangerous - because one falls easily into the trap of using another unsupported ALIGN values, that's why I favor the wxTE values

comment:13 Changed 5 years ago by csomor

documentation fix in r71960

comment:14 Changed 5 years ago by SC

(In [71964]) supporting alignment in single line controls, see #14452

comment:15 Changed 5 years ago by VZ

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

(In [72416]) Explicitly reject the use of wxTE_PASSWORD in generic wxSpinCtrl.

wxTE_PASSWORD has the same value as wxALIGN_CENTRE_VERTICAL which could be
implicitly specified as part of wxALIGN_CENTRE, but should never be used with
wxSpinCtrl, so explicitly filter it out when creating the associated
wxTextCtrl.

Closes #14452.

Note: See TracTickets for help on using tickets.