如何在 Mac OSX 中获取和/或覆盖窗口的最小大小 [英] How to get and/or overwrite the minimum size of windows in Mac OSX

查看:36
本文介绍了如何在 Mac OSX 中获取和/或覆盖窗口的最小大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 GUI 调整我机器上任何窗口的大小,这是我用 AppleScript 完成的脚本.该脚本类似于以下内容:

I want to resize any window on my machine, which I accomplish with AppleScript, using GUI Scripting. The script looks similar to the following:

tell application "System Events"
  set appProcess to the first process whose name is "Finder"
  set appWindow to the front window of appProcess
  set position of appWindow to {100, 100}
  set size of appWindow to {10, 10}
end tell

即使我将宽度和高度设置为 10 像素,Finder 也会调整到至少 344 像素的宽度和 236 像素的高度.我用其他应用程序对此进行了测试,并且所有应用程序都有一个最小宽度,这取决于应用程序.例如,TextMate 窗口的大小至少为 213px * 129px.

Even though I set the width and height to 10px, the Finder will resize to at least a width of 344px and a height of 236px. I tested this with other applications and all had a minimum width, which differed depending on the application. For example, TextMate windows have a size of at least 213px * 129px.

由于我有时需要将窗口大小调整为较小的宽度和高度,有没有办法覆盖这个最小尺寸,即即使我的值太小",也会使用它们?

Since I sometimes need to resize the windows to a smalled width and height, is there a way to override this minimum size, i.e. that my values are used even though they are "too small"?

如果不是,我需要知道最小尺寸,以便我知道窗口会比预期的大.我将如何做到这一点?

If not, I need to know the minimum size, so that I know that the window will be bigger than expected. How would I accomplish that?

具体问题如下:我正在编写一个窗口平铺管理器,因此我需要负责窗口的大小.最小尺寸会产生问题:

The concrete problem is the following: I am writing a window tiling manager, therefore I need to be in charge of the size of the windows. The minimum size creates to problems:

  1. 对于某个应用程序的窗口,我的磁贴可能太小,因此这些窗口可能会在其他磁贴中重叠.
  2. 窗口可能比预期的更宽/更高,因此跨越了我的屏幕边界.(例如,窗口靠近我屏幕的右下角 - 我相应地设置了宽度和高度以适合角落,但由于它有最小尺寸,因此不适合.)

感谢您的任何建议.:)

I am thankful for any recommendations. :)

最好的祝福
弗洛里安

Best wishes
Florian

推荐答案

正如评论者所指出的:无法将窗口的大小调整为低于其在开发过程中(例如在 Interface Builder 中)设置的最小大小. 但是,最小尺寸的存在是有原因的:为了防止自动调整大小问题,例如由于视图尺寸太小,按钮重叠或消失.

As the commenters pointed out: It is not possible to resize a window below its minimum size which was set during development (e.g. in Interface Builder). However, minimum sizes are there for a reason: To prevent auto-resizing problems, e.g. buttons overlap or disappear due to a too small view size.

感谢巴伐利亚的回答.

PS:Lri 补充说,可以使用应用程序的 API 绕过最小尺寸,例如使用 Carbon API 调整 iTunes 的大小或使用自定义构建的 AppleScript-API.谢谢丽丽!

PS: Lri added, that it may be possible to bypass minimum sizes using the API of an application, e.g. using the Carbon API to resize iTunes or using customly build AppleScript-APIs. Thanks Lri!

这篇关于如何在 Mac OSX 中获取和/或覆盖窗口的最小大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆