Horizontally scrolling NSCollectionView does not scroll until window resize - swift

I have a horizontally scrolling NSCollectionView. The items are created but it is not scrollable until I manually resize the window in a horizontal direction. After that I scrolls fine. Does anybody know how to fix this? I looked at this question (question link) and tried the suggested solutions but I think its a different problem since it works after resizing the window.
EDIT:
The collection view is in a tableview cell. I have other collection views (although vertically scrolling and not in a tableview cell) in the same application and they work fine.

I solved it just by add this on my collectionView:
[self.yourCollectionView setFrameSize:self.yourCollectionView.collectionViewLayout.collectionViewContentSize];

I been experiencing similar issue for so many years and finally figured out that this is caused by Xcode.
When force quitting your application with Xcode (by ether clicking Run or Stop when application is running), Xcode saves the window's frame and restore it on next launch, even when your window is not configured to autosave its frame.
This is good for development but for some reasons, this causes the document view of the scroll view (mostly collection view) to not use the correct bounds in the next application run.
Manually setting collection view's frameSize as many people suggested doesn't always works. However, if you quit your application normally:
Click Application Menu and select Quit Application Name
Use keyboard shortcut ⌘Q
Right click on Dock icon and select Quit (with ⌥ or not)
Force quit in Force Quit Applications window (⌘⌥⎋)
...
Anything will works as you expected in the next application run (including launching from Xcode).

Related

Cocoa Swift: Connect Main Menu to Preferences Window Controller & Disabling Items like Minimise in Attributes Inspector doesn't work in Xcode?

I have a simple Menubar app in which it has 2 options - namely Preferences & Quit
After clicking on Preferences it opens a new window but doesn't show the menu bar
I tried connecting from Main Menu to the Window Controller but it doesn't work.
I drag it from the Application Name to the Window Controller or View Controller using Ctrl+Drag but still it doesn't work.
Another issue is my Preferences Window is resizing even though I unchecked the resize button in the Attributes Inspector.
Even Maximise & Minimise checkboxes are disabled but they are still showing.
Any solutions?
See NSApplication.activationPolicy.
If you want the app's main menu bar to appear, you'll need to change the activationPolicy to NSApplicationActivationPolicyRegular. Once you do that, the app's main menu will appear when your app is the active one. (It will also appear in the dock.)
If you want this to happen only when your preferences window is open, then you'll need to change the activationPolicy when the window opens, then set it back again when it closes.
You don't need to connect any outlets for this; the Main Menu should already be a resource for your app and should be loaded automatically when your app launches.
I think I had given Storyboard Id to my View Controller rather than my Window Controller so it wasn't working.
I also checked some apps like Dropbox which didn't have Main Menu Bar because it was a background or accessory app so I ditched it.
Some apps like Focus have it though. But I went with the popular choice.
As for no resizing, no minimising & no maximising goes, I pasted below code & it worked
var myWindow: NSWindow? = nil
myWindow?.styleMask.remove(NSWindow.StyleMask.resizable)
myWindow?.standardWindowButton(.miniaturizeButton)?.isEnabled=false
myWindow?.standardWindowButton(.zoomButton)?.isEnabled=false

Google Chrome color picker isn't responding

Google Chrome color picker isn't responding. I tried re-installing and resetting Chrome. How can this be resolved?
"Reset devtools" doesn't fix the issue. I am not entirely sure what the exact cause of this bug is, but the only fix available will need to be done in an update. I could not find it in the code itself, although I didn't spend much time looking.
The main issue is that when your dev tools are docked to the bottom of the window, then the color picker will not show. It will load though, but the interface wont show. More than likely it is either in the wrong layer, or has some issue with its actual display, as no errors are thrown.
Anyway, the reason resetting dev tools works is because the default setting is to dock the dev tools to the right side of the screen (presumably, their testing showed most users use a wide screen, multiple screen, setup; as a result, there is room on the side of the screen).
If you, like me, use dev tools docked to the bottom, then in order to see the color picker, you need to change the dev tool temporarily to be docked to the right side of the screen. This does not require the settings to be reset, just simply change the docking position.
if your color picker not working on your mouse pointer, then you have to change your display settings, if your display settings are at scale 125 or more then your color picker won't work in any of the browsers, if you change your display setting to 100% your color picker will automatically start working
Changing the window size brings back the color picker. If the window is full screen size, get out of full screen size.
The solution that worked for me is:
Get out of full screen mode (Un-maximize window).
Reduce the window size, specially the width.
Docking the dev-tools to right side, Scaling the display, Lowering display resolution also brings the color-picker back as all of these affects the browser window size. Hopefully this bug will be addressed soon.
Open the inspect elements -> go to settings -> Preferences -> scroll down to the end you will see button "Restore defaults and reload" -> click on it and it will work
I had the same issue on Chrome 108.0.5359.98 on Arch for a long time now.
The problem was fixed by simply unchecking one of the experiments in DevTools - Settings - Experimets - Enable color picking outside the browser window.
scale your display settings to 100 % and again re scale to 125%(recommended).
For me chaning the Devtools zoom size worked not the webpage size.
Ctrl + Mouse wheel zooms in or out on the dev tools dock.
The problem is quite simple. You are unable to use the color picker because you have enabled the mobile view or any other device view
and, you got the answer, you just need to close the device toolbar and you are good to go.
Hope that works 😃

NSPopover OS X Application

I am developing a menu bar application for os x. I am using NSPopover to create a popup window.
However when some other application is full screen that popup is not visible. What settings should be set, so that popup window is always on top.
I struggled with this as well. When I had this problem, I created a invisible window that would flow above all other windows, including full screen ones. The window would then activate the popover.
However, I found a much cleaner solution here.

Eclipse/Win7 - Scrolling in Content Assist with mouse without focus

Recently switched from Linux to Windows for development in Eclipse Indigo SR1. In Linux, if I Ctrl-Space'd to open a Content Assist window, I could immediately start scrolling with the mouse wheel (with the cursor over the Content Assist window of course).
Now, in Windows 7, if I try to scroll in the same way the Content Assist window goes away, and whatever editor I have open is scrolled instead.
If I first press Tab to give focus to the Content Assist window, the mouse wheel scrolling works as expected, but I'd much rather it behaved as it did for me on Linux, rather than retrain myself to press Tab every time.
Is there a way to make the mouse work this way with Eclipse?
Found an answer that appears to work. It's a little dated but seems to still do the trick.
http://divby0.blogspot.com/2007/04/focus-follows-mouse.html
Dropped this jar in the eclipse plugins folder and restarted. At first I thought it didn't work, but later I noticed there is a little X button added to your toolbar that you need to toggle. Scrolling seems to work properly now.

Horizontal scrolling with the scrollwheel in Eclipse

I've been trying to find a way to scroll the text horizontally with my scrollwheel in Eclipse, similar to the way you can do it in Textpad. In Textpad if you hold ctrl while you scroll vertically it will scroll horizontally. Does anybody know if there is a configurable setting somewhere in Eclipse that will allow this? I've looked all over the "keys" setting page without being able to find it, and Google/Stack Overflow searches haven't turned anything up for me.
Thanks.
I guess this depends more on your OS than on Eclipse. For instance on Mac OS it's Shift + Scrolling.
#Daniel Sokolowski's answer was almost working. I have been using X-Mouse Button Control for over a year now and didn't know how to get the Horizontal Scrolling to work on certain programs (like Eclipse and Chrome) until I read Sokolowski's answer which pointed me in the right direction.
For the sake of brevity, and not to duplicate what has already been written clearly by Sokolowski, follow his directions, and in addition do the following:
Add Eclipse to your Applications list in X-Mouse by clicking Add and finding javaw.exe in the "Choose Application" popup and clicking OK.
Now click on the "Eclipse" profile and choose the "Scrolling & Navigation" tab
Under the "Advanced Window Scrolling" choose Method 1(SCROLL Msg) option for Scroll Method
Click Apply
If you correctly followed Sokolowski's and my instructions together you should be able to press Shift while scrolling up or down to trigger a horizontal scroll.
On a Windows machine this worked for me:
Download X-Mouse Button Control
In the main window go to 'Layer 2' and change 'Wheel Up' and 'Wheel Down' to 'Scroll Windows Right' and 'Scroll Window Left'
Go into the 'Settings > Modifier Keys Tab' and select 'Shift' for the 'Activate Layer 2' setting.
Now in whatever active window, including Eclipse pressing shift and then scrolling up and down will scroll horizontally.
Update: I have been using this approach for a few days now and noticed that not all windows are horizontal scroll enabled, for example 'Package Explorer' is not but 'Navigator' is - this appears to be a limitation of Eclipse IDE rather than this approach. Please take a moment and upvote this Eclipse Bug #201984
You have a plugin supposed (not tested) to support horizontal scrolling.
But without plugin, SWT does not support horizontal scrolling on Windows.
Its support is planed for 3.6 though. (since 3.6M2, actually -- September 18, 2009)
New event constants have been added for horizontal mouse wheels.
See SWT.MouseHorizontalWheel and SWT.MouseVerticalWheel.
For me the best way while using eclipse or for that matter any IDE, is to have a new line char at the end of screen. I feel that to use horizontal scrolling to view data becomes bit difficult while going back and forth and I would like all code to be visible to me always. If the code you are trying to view requires you to use horizontal scroll bar then try to format it by using Ctrl+Shift+F.
The bug has been fixed in the latest update of Eclipse.
In your Eclipse menu bar, simply:
1. Click Help>Check for Updates.. (and wait for the progress bar at the bottom to finish checking)
2. Install all updates.
Once Eclipse IDE gets restarted, you are now able to scroll horizontally.
(Save yourself from having to install additional mouse softwares to create new configurations. Phew, I'm so glad I figured this one out for myself)
Cheers!