pyglet window resize - problem when maximizing / restoring window - resize

I am building a simple menu bar for my Pyglet app. I would like to stick the menu on the top left corner of the window, and also I would like my menu to have the same width of the window but fixed height.
So what I've done is to add a local_on_resize method that calls my menu resize method that performs all the necessary transformations.
def local_on_resize(self, x, y):
self.menu.resize(self.width, self.height)
and this method is pushed in this way in the window constructor:
self.push_handlers(on_resize=self.local_on_resize)
This seemed to work, as if I try to resize the window by dragging the borders of my window the menu gets resized correctly. The problem comes when I try to maximize/restore my window. In fact when I click on the maximize button the window gets maximized but I get a black screen (the menu bar disappears). However, if I try to click anywhere, or raise any event, the menubar reappears correctly. Same thing for restore button: if I restore my window, the menubar disappears but it gets back if I click on the window. So what I see if that the resize mechanism seems to work when I resize the window "continuously" by dragging it, but doesn't work when I maximize/restore it.
Does anybody know how can I fix this?

Related

Sliding a frameless window in and out of screen edge in qml

As the title says, I want to move, clicking a button in task bar , a frameless window out and in of screen right edge .One way to achieve this under kde neon in QML, is to create a PlasmaCore.Dialog{} window and setting as flags the Qt.X11BypassWindowManagerHint only, so the window manager is bypassed.The problem with this solution is that, inside window, where i "append" some widgets in a ListView, I can not have activeFocus to TextArea and I can not type anything there. The TextArea gains activeFocus only if I use as flags the Qt.Popup only without Qt.X11BypassWindowManagerHint.
So is there an alternative solution of making the window sliding in an out from screen right edge without using the flags of Qt.X11BypassWindowManagerHint? In the below link is the code I am using now for sliding window:
https://gist.github.com/cgiannakidis70/8a0ea61d7f18e803381159d7456e2135
EDIT 1
After a lot trying and error I found that the use of flags Qt.BypassWindowManagerHint and Qt.Popup do the trick.Now I can slide the window outside screen edge and also type in TextArea inside a widget .

update KeyboardAvoidingView after a layout change

I have a form in my app that has a floating bar with buttons that animates into the view at the bottom of the window when the user makes any change to any of the data in the form. I have this bar rendering relative to the height of the window so it knows when the keyboard is open or closed and will attach to wherever the bottom of the view window is at any give time.
The issue I have is the form is wrapped in a KeyboardAvoidingView around the form with a behavior of padding and this all works great, however when I make my change and my floating button bar comes up, because the input is at the bottom of the window the bar now covers up the input I'm typing in.
I haven't been able to find a way to fix this yet. I tried disabling the KeyboardAvoidingView I assume that maybe I need to somehow tell the view about this bar that's covering up part of the view but I'm not sure how I do that.
here is a snapshot of what this looks like for reference...

Activate all windows from background when clicking on main window

I have an Objective-C application with a main window and a small progress window with a stack view to show the current progress.
If the application is put in the background by activating any other application and then clicking on the Dock icon, both the Main and secondary windows is brought to the front and shown.
But, if I just click one of the windows when in the background, only that window is activated and brought to the front, the other stays in the back.
I want to implement so that when I click on the main window it does the same thing as clicking on the Dock icon, it should show both windows on top with the Main window activated.
But if I click on the progress window, I don't want the main window to be brought to the front.
I haven't been able to find a way to do this, how should I go about achieving this?
You can detect the window being clicked with the window delegate's -windowDidBecomeKey: or -becomeKeyWindow, or the app delegate's -didBecomeActive:.
Then depending on your exact needs, you can use [NSApp activateIgnoringOtherApps:] or [[NSRunningApplication currentApplication] activateWithOptions:] (and possibly NSApplicationActivateAllWindows).

Any clue why these elements are being drawn in another view?

This strange behaviour happens when I have another window over my main window and perform a command that opens a modal popup in the main window. The outline of the selector and the Approved button are drawn in the modal window like the images show:
Where I think the elements are coming from:
However, if the window becomes out of focus and in focus again, the elements disappear.
Well, it seems I solved it. I don't know exactly why it was happening, but it probably had something to do with the multiple calls I was doing to - (void)drawRect:(NSRect)dirtyRect; in order to modify the selector border when hovering the mouse. Now I call my custom method, - (void)showBorder; which does only: self.layer.borderWidth = 1.0;.

Resize NSWindow from bottom left corner only?

I am writing an application that sits in the OS X menu bar and when you press its icon a little NSPanel opens up. I would like the user to be able to resize it, but only by dragging the bottom left corner. I want to prevent them from being able to drag the top edge down and "unstick" the window from the menu bar.
Just override touchesBegan mouseDown: and pass on the drag only if it is in the designated corner, discarding other touches.
See Cocoa Event Handling Guide