在 Maxscript 中为按钮上的字母下划线
Underline a letter on a button in Maxscript
我一直在寻找一种方法来执行此操作,例如在 queryBox 中,其中 Y 和 N 的 Yes 和 No 下划线表示如果您按下它们,就会按下它们。
这是我在 Button 之前放置一个符号的代码和错误的屏幕截图。
try destroyDialog testRol catch()
rollout testRol "testRol" (
button btn_test "&Button"
)
createDialog testRol 100 45
编辑:
即使我尝试 \x0332Yes
也没有用。确实如此,但下划线没有正确排列,并且在 B
之前使用时看起来一团糟。
我使用了硬编码的带下划线的字母,但效果并不理想,所以如果有人知道可以很好地避免这种情况的解决方案。
下面是尝试,因为它可能会帮助您解决这个问题:
try destroyDialog testRol catch()
rollout testRol "testRol" (
button btn_yes "Y̲es (Working)" width:120 across:4
button btn_no "N̲o (Working)" width:120
button btn_button_not_working "\x0332Button (Not Working)" width:120
button btn_yes_not_working "\x0332Yes (Kinda Working)" width:120
)
createDialog testRol 525 45
根据您的期望,您可以在 rollout 控件中使用 .NET 按钮 但是您必须自己设置样式以匹配主题并使用系统样式来制作它看起来像 maxscript 按钮:
try destroyDialog testRol catch()
rollout testRol "MXS + .NET"
(
dotNetControl btnMakeCylinder "Button" text:"&Make Cylinder" width:120 height:25
on btnMakeCylinder mouseClick evnt arg do with undo on Cylinder isSelected:on
on testRol open do btnMakeCylinder.FlatStyle = btnMakeCylinder.FlatStyle.System
)
createDialog testRol
或者您可以使用 MaxForm,其中按钮将继承颜色,但它仍然看起来不像 UI 的其余部分:
(
local form = dotNetObject "MaxCustomControls.MaxForm"
form.Text = ".NET form"
fn makeCylinder = with undo on Cylinder isSelected:on
local btnMakeCylinder = dotNetObject "Button"
btnMakeCylinder.Text = "&Make Cylinder"
dotNet.addEventHandler btnMakeCylinder "MouseClick" makeCylinder
form.Controls.Add btnMakecylinder
form.ShowModeless()
)
或者您可以使用 Qt UI,它有自己的一系列缺点(比如必须始终明确指定撤消记录),而且它相当冗长:
(
local legacy = (python.import "sys").version_info[1] < 3
local QtGui = python.import "PySide2.QtGui"
local QtWidgets = python.import "PySide2.QtWidgets"
local GetQMaxMainWindow = (if legacy then python.import "MaxPlus" else python.import "qtmax").GetQMaxMainWindow
if isProperty ::testQtDialog #close do testQtDialog.close()
testQtDialog = QtWidgets.QDialog(GetQMaxMainWindow())
testQtDialog.setWindowTitle "Qt Window"
local dialogLayout = QtWidgets.QVBoxLayout()
fn makeCylinder = with undo on Cylinder isSelected:on
local btnMakeCylinder = QtWidgets.QPushButton "&Make Cylinder"
btnMakeCylinder.clicked.connect makeCylinder
dialogLayout.addWidget btnMakeCylinder
testQtDialog.setLayout dialogLayout
testQtDialog.show()
)
从 2022 年开始,您还可以通过这种方式使用本机最大控件制作 Qt windows:
if isKindOf testQtRol RolloutClass do UIAccessor.closeDialog testQtRol.hwnd
rollout testQtRol "Qt Rollout"
(
QtButton btnMakeCylinder "&Make cylinder" row:0 column:2
on btnMakeCylinder pressed do with undo on Cylinder isSelected:on
)
createQtDialog testQtRol
我一直在寻找一种方法来执行此操作,例如在 queryBox 中,其中 Y 和 N 的 Yes 和 No 下划线表示如果您按下它们,就会按下它们。
这是我在 Button 之前放置一个符号的代码和错误的屏幕截图。
try destroyDialog testRol catch()
rollout testRol "testRol" (
button btn_test "&Button"
)
createDialog testRol 100 45
编辑:
即使我尝试 \x0332Yes
也没有用。确实如此,但下划线没有正确排列,并且在 B
之前使用时看起来一团糟。
我使用了硬编码的带下划线的字母,但效果并不理想,所以如果有人知道可以很好地避免这种情况的解决方案。
下面是尝试,因为它可能会帮助您解决这个问题:
try destroyDialog testRol catch()
rollout testRol "testRol" (
button btn_yes "Y̲es (Working)" width:120 across:4
button btn_no "N̲o (Working)" width:120
button btn_button_not_working "\x0332Button (Not Working)" width:120
button btn_yes_not_working "\x0332Yes (Kinda Working)" width:120
)
createDialog testRol 525 45
根据您的期望,您可以在 rollout 控件中使用 .NET 按钮 但是您必须自己设置样式以匹配主题并使用系统样式来制作它看起来像 maxscript 按钮:
try destroyDialog testRol catch()
rollout testRol "MXS + .NET"
(
dotNetControl btnMakeCylinder "Button" text:"&Make Cylinder" width:120 height:25
on btnMakeCylinder mouseClick evnt arg do with undo on Cylinder isSelected:on
on testRol open do btnMakeCylinder.FlatStyle = btnMakeCylinder.FlatStyle.System
)
createDialog testRol
或者您可以使用 MaxForm,其中按钮将继承颜色,但它仍然看起来不像 UI 的其余部分:
(
local form = dotNetObject "MaxCustomControls.MaxForm"
form.Text = ".NET form"
fn makeCylinder = with undo on Cylinder isSelected:on
local btnMakeCylinder = dotNetObject "Button"
btnMakeCylinder.Text = "&Make Cylinder"
dotNet.addEventHandler btnMakeCylinder "MouseClick" makeCylinder
form.Controls.Add btnMakecylinder
form.ShowModeless()
)
或者您可以使用 Qt UI,它有自己的一系列缺点(比如必须始终明确指定撤消记录),而且它相当冗长:
(
local legacy = (python.import "sys").version_info[1] < 3
local QtGui = python.import "PySide2.QtGui"
local QtWidgets = python.import "PySide2.QtWidgets"
local GetQMaxMainWindow = (if legacy then python.import "MaxPlus" else python.import "qtmax").GetQMaxMainWindow
if isProperty ::testQtDialog #close do testQtDialog.close()
testQtDialog = QtWidgets.QDialog(GetQMaxMainWindow())
testQtDialog.setWindowTitle "Qt Window"
local dialogLayout = QtWidgets.QVBoxLayout()
fn makeCylinder = with undo on Cylinder isSelected:on
local btnMakeCylinder = QtWidgets.QPushButton "&Make Cylinder"
btnMakeCylinder.clicked.connect makeCylinder
dialogLayout.addWidget btnMakeCylinder
testQtDialog.setLayout dialogLayout
testQtDialog.show()
)
从 2022 年开始,您还可以通过这种方式使用本机最大控件制作 Qt windows:
if isKindOf testQtRol RolloutClass do UIAccessor.closeDialog testQtRol.hwnd
rollout testQtRol "Qt Rollout"
(
QtButton btnMakeCylinder "&Make cylinder" row:0 column:2
on btnMakeCylinder pressed do with undo on Cylinder isSelected:on
)
createQtDialog testQtRol