-
-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Double click on ToolBarIconButton maximises window #308
Comments
@whiplashoo any thoughts on how we can account for this? Perhaps an |
The issue is that the double click behavior is handled by the native |
I wonder if there's a way to block double-click events for widgets |
@GroovinChip / @whiplashoo any ideas how we could solve this? |
Unfortunately, I do not. Hopefully @whiplashoo might. |
I guess if we don't want to draw the whole window decorations ourselves, using This is just a proof of concept. We might want to use a class BlockingToolbar: NSToolbar, NSToolbarDelegate {
let flutterView: BlurryContainerViewController
init(flutterView: BlurryContainerViewController) {
self.flutterView = flutterView
super.init(identifier: "BlockingToolbar")
}
func toolbarDefaultItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] {
[.flexibleSpace, NSToolbarItem.Identifier("BlockingItem")]
}
func toolbarAllowedItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] {
toolbarDefaultItemIdentifiers(toolbar)
}
func toolbar(_ toolbar: NSToolbar, itemForItemIdentifier itemIdentifier: NSToolbarItem.Identifier, willBeInsertedIntoToolbar flag: Bool) -> NSToolbarItem? {
if itemIdentifier == NSToolbarItem.Identifier("BlockingItem") {
let item = NSToolbarItem(itemIdentifier: itemIdentifier)
let myView = ForwardingView()
myView.flutterView = flutterView
item.view = myView
return item
}
return nil
}
}
class ForwardingView: NSView {
var flutterView: BlurryContainerViewController?
override var intrinsicContentSize: NSSize {
NSSize(width: 50, height: 50)
}
override func mouseDown(with event: NSEvent) {
flutterView!.flutterViewController.mouseDown(with: event)
}
override func mouseUp(with event: NSEvent) {
flutterView!.flutterViewController.mouseUp(with: event)
}
} Used like this in if #available(macOS 10.13, *) {
let customToolbar = BlockingToolbar(flutterView: blurryContainerViewController)
customToolbar.showsBaselineSeparator = false
customToolbar.delegate = customToolbar
self.toolbar = customToolbar
} @whiplashoo / @GroovinChip what do you think? |
Hard to say without trying it out, which I can't because I'm AFK. Can you post a gif of this in action? |
Sure, here you go: Screen.Recording.2023-02-19.at.22.30.26.mov |
Looks great, thank you! I agree with you that keeping |
I don't have much time for more than this quick example in the next month. If you like it please feel free to build on this. Otherwise I might get back to this issue later. |
Fair enough. I'll see if I can knock something together. |
A variation of the code above could be to have a single Code above coule be changed like this: class BlockingToolbar: NSToolbar, NSToolbarDelegate {
let flutterView: BlurryContainerViewController
init(flutterView: BlurryContainerViewController) {
self.flutterView = flutterView
super.init(identifier: "BlockingToolbar")
}
func toolbarDefaultItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] {
[.flexibleSpace, NSToolbarItem.Identifier("BlockingItem")]
}
func toolbarAllowedItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] {
toolbarDefaultItemIdentifiers(toolbar)
}
func toolbar(_ toolbar: NSToolbar, itemForItemIdentifier itemIdentifier: NSToolbarItem.Identifier, willBeInsertedIntoToolbar flag: Bool) -> NSToolbarItem? {
if itemIdentifier == NSToolbarItem.Identifier("BlockingItem") {
let item = NSToolbarItem(itemIdentifier: itemIdentifier)
let view = ForwardingView()
view.flutterView = flutterView
view.widthAnchor.constraint(lessThanOrEqualToConstant: 100000).isActive = true
view.widthAnchor.constraint(greaterThanOrEqualToConstant: 1).isActive = true
item.view = view
return item
}
return nil
}
}
class ForwardingView: NSView {
var flutterView: BlurryContainerViewController?
override func mouseDown(with event: NSEvent) {
flutterView!.flutterViewController.mouseDown(with: event)
}
override func mouseUp(with event: NSEvent) {
flutterView!.flutterViewController.mouseUp(with: event)
}
} Used like this in if #available(macOS 10.13, *) {
let customToolbar = BlockingToolbar(flutterView: blurryContainerViewController)
customToolbar.showsBaselineSeparator = false
customToolbar.delegate = customToolbar
self.toolbar = customToolbar
} |
@cbenhagen I am reluctant to use external plugins for features as it increases our dependency on others, which reduces our ability to iterate on our own timetable. |
I understand. Nothing is holding us back to just implement the zoom part on our own. |
I added a PR to macos_window_utils using the BlockingToolbar described above. |
Description
Double click on
ToolBarIconButton
maximises windowSteps To Reproduce
Expected behavior
ToolBarIconButton
should not pass mouse events to windowScreen recording
toolbar.mov
The text was updated successfully, but these errors were encountered: