I'm working on adding support in my app for full-height sidebars, as introduced in macOS 11.
The trick is, when the window tab bar is visible, I want to turn the full-height sidebar off. The two don't mix well when the sidebar content is different in each window, as it is in my app. See Xcode for an example of what I want to do (View > Show Window Tab Bar). See Preview for an example of what I want to avoid (open two multi-page PDFs and put them in a single tabbed window).
What's working:
I observe the window's tabbedWindows property, and toggle the fullSizeContentView flag in its styleMask accordingly. Thus the window's style updates as needed when I hide and show the tab bar.
What's not working: I need to have a sidebarTrackingSeparator item in my toolbar in order to have some items above the sidebar. But when fullSizeContentView is off, that item appears as a plain separator. I don't want it to be visible at all in that state.
There isn't a straightforward way to hide a toolbar item, especially if it doesn't have a view, which it turns out this one doesn't.
I tried removing the separator item and re-adding it when the window state toggles, but that leads to Cocoa throwing exceptions, complaining that only one tracking item can be registered at a time. This would seem to be a bug, but Xcode manages it somehow.
So how can I properly toggle my window and toolbar state without having that visible separator?
It looks like I've solved the problem by saving the separator item when I see it in toolbarWillAddItem, and then returning it from toolbar(_:itemForItemIdentifier:willBeInsertedIntoToolbar:) to avoid having a new instance created. That way, removing and re-adding the item works without having exceptions thrown.
The last little snag was to not remove and re-add the separator blindly. The window state may have been preserved across app launches, so I needed to not make assumptions about how the window would initially appear.
Related
There are two places within Xcode (version 13.3) where I can't drag and drop anymore.
Trying to move a file to a Group. I have tried just clicking and dragging, control-click, option-click, command-click, none work. Instead of dragging the file, the cursor just moves without the selected/highlighted file and highlights whatever file or group it is hovering over.
Trying to drag a button to a View Controller to make a connection. Instead, a popup window appears with three rows, each with corresponding icon, two lines each (title and object type): View Controller, View, Button. (I can't figure out how to capture that screen since I am already holding the control key and mouse button (track pad) but here is a photo.
Update:. All works fine when using a mouse but these two problems always exist when using the trackpad. I did discover that by pressing the Escape key, I can perform the control-drag (but not move files). I have played with the trackpad settings but have not yet been able to figure out how to get rid of that window that appears.
This popup appears whether I am holding the control, option, or command key.
What xcode version are you using, just tried
#1 is working as expected on my xcode13.0
#2 seems to be working for me too..
I originally had code that set the focus to the first widget in a dialog, in the onInit method. But there were problems with it: if I pressed TAB, indeed focus moved to next control (wxTextCtrl), which got the blue 'focus' color, but the 'focus' color/highlight was not removed from previous focus widget. So now it looked like both first and second control had focus at the same time...
When cycling manually (by pressing TAB) full circle (till last control and then wrap around to the first), suddenly all worked well. That is, when moving focus from first control to next one, the first visually lost focus (blue color was removed) as it should. From now on, only one item had the focus color/highlight.
So instead of setting focus on the first control, I tried a different approach: I set the focus to the last control in the dialog, which is always the OK button. Next, I want to emulate programmatically that a TAB is pressed and received by the dialog. So I wrote this (inside Dialog::onInit):
m_buttonOK->SetFocus();
wxKeyEvent key;
key.SetEventObject(this);
key.SetEventType(wxEVT_CHAR);
key.m_keyCode=WXK_TAB;
ProcessWindowEvent(key);
Now the focus indeed moves away from the OK button, but it does not wrap around to the first control.
Only when I manually press TAB after the dialog opened, the first item gets focus.
Question: why does this wrapping around to set focus on first widget not work with the code shown above?
First of all, your initial problem is almost certainly related to not calling event.Skip() in one of your event handlers, see the note in wxFocusEvent documentation.
Second, you can't send wx events to the native windows, they don't know anything about it. In this particular case you can use wxWindow::Navigate() to do what you want, but generally speaking what you're doing simple can't, and won't, work reliably.
I what to display some text, probably using DrawText() on to the CTabView client area when no tabs exist to explain why they don't exist. However, CTabView::OnPaint() is not called except once at the app startup. Also when all tabs hidden the CTabView::OnDraw() is not called. I suppose the CMFCTabCtrl may be the one getting the OnPaint() callbacks? But nonetheless, how do you output something to that row/col of a CSplitterWnd occupied by a CTabView when all tabs are not shown (hidden via CMFCTabCtrl::ShowTab()). ??
TIA!!
The tab control works that way that all tab views are hidden - except the one which is open.
Where no tab view is open, none will receive a paint message (nor WM_ERASEBACKGROUND).
You could try implementing your paint stuff in the tab control's OnPaint handler.
I have a CRichEditCtrl with auto vertical scrolling set, which works, but not quite as I'd like. The text in the control can be updated via a message from another thread, so it can be busy updating while the user does other things, but the way it updates is different depending on whether it has focus or not (whether or not the caret is blinking). If it has focus, it auto scrolls to the most recent text (at the bottom of the window), without focus you can see the scroll bar shrinking as text is added but there is no actual scroll. Is there any way of getting it to always scroll to the bottom, so that the user always sees what's been most recently added?
I've tried sending EM_SCROLLCARET after ReplaceSel() but it made no difference. Also tried using LineScroll(), but that puts the most recent line at the top of the window, not at the bottom as happens when auto scrolling - this can also result in a blank window if there are trailing new lines ...
Looking on MSDN/forums I can't see much else to try.
Cheers for any help.
I have CMenu instance on which I add multiple items. For one of the items I added in it, I set the MF_HILITE flag.
When I show the menu, the appropriate item get hi-lighted correctly, as requested. The problem is that it stays hi-lighted until I move the mouse over it and leave. I only want one item to be hi-lighted at the time. It seems that Windows does not un-light it when another item is hi-lighed.
How could I force it to be un-lighted as soon as another item get the hi-light? I could not find any mouse-over callback or message for the menu, and I could not find a invalidate either.
You're using MF_HILITE in a weird way. The item isn't actually highlighted, it's just drawn like it is. If the user presss enter, the "highlighted" item won't be selected.
You're probably looking for MF_DEFAULT.
It does not appear to be possible.
The internal state for the currently selected item in the menu can't be set. Using the MF_HILITE or HiliteMenuItem does not set the currently selected item, it only sets the visual style.
As a work-around, I have used a popup ListBox instead, which has all the features I need.