After "playing" with the coordinates, I looked into customizing the NSTextView. I added following code and bunch of scaffoldings.
Code: Select all
bool wxNSTextViewControl::DoSetMargins(const wxPoint& pt)
{
[m_textView setTextContainerInset:NSMakeSize(static_cast<float>(pt.x),
static_cast<float>(pt.y))];
return true;
}
wxPoint wxNSTextViewControl::DoGetMargins() const
{
NSSize s = [m_textView textContainerInset];
return wxPoint(s.width, s.height);
}
However, now I can set the inset to 0 and wxTextCtrl::GetMargins() returns the inset 0, but on UI it makes no difference. Setting margin width to 0 change nothing, but setting to 10 does work. Margin height doesn't affect anything. But the whole stackoverflow is suggesting to set the inset.
Could anyone familiar with NSTextView shed some light on this? And what is the wxNSTextFieldControl used for? It seems has nothing to do with wxTextCtrl. If I want to implement the Get/SetMargins, should I leave wxNSTextFieldControl with the default implementation? (which does nothing)
Thanks!
-------------------------------------
Okay... macOS text display is complicated. By adding more code, I have made it. Reference of those text layout names at
https://developer.apple.com/library/con ... rgins.html
Code: Select all
bool wxNSTextViewControl::DoSetMargins(const wxPoint& pt)
{
[m_textView setTextContainerInset:NSMakeSize(static_cast<float>(pt.x),
static_cast<float>(pt.y))];
[[m_textView textContainer] setLineFragmentPadding:0.f]; // hard-coded 0 here
return true;
}
Then it seems to be a very specific implementation. I will try to make a patch.
In case anyone is looking for a solution before I submit the patch, here it is:
https://github.com/xinhuang/wxWidgets/c ... 8a4098cd66