[英]Easy way to display alert
Is it possible to display an alert for user in an easy way? 是否可以通过简单的方式为用户显示警报? Something like: 就像是:
save
title
ifEmpty: [ 'Title cannot be empty' alert ]
ifNotEmpty: [ "…do the saving…" ]
so that if title
ivar will be empty user will see the dialog with appropriate message. 因此,如果title
ivar将为空,则用户将看到带有相应消息的对话框。
You can (somewhat) tweak the dialog window before showing it up with a block. 您可以(有点)调整对话框窗口,然后再显示一个块。
Like centering it on screen with a red border. 就像在屏幕上居中显示红色边框一样。
UIManager default
alert: 'Something is wrong'
title: 'Issue ahead'
configure: [ :d | d position: Display center; borderColor: Color red].
it would be: 这将是:
self inform: 'Title cannot be empty'
but to be honest, I'm not happy with it, because is like a growl notification. 但老实说,我对此不满意,因为这就像咆哮的通知。
Most of the time, that's exactly what you want, but some times you need a modal notification... anyway, that's what you need :) 在大多数情况下,这正是您想要的,但是有时您需要模式通知...无论如何,这就是您所需要的:)
yes it is 是的
for a typical error dialog you can use this piece of code 对于典型的错误对话框,您可以使用这段代码
UIManager default abort: 'Title cannot be empty'.
for a growl messages that the user has not to click on ok button you can use this 对于用户不必单击“确定”按钮的咆哮消息,您可以使用此
UIManager default inform: 'Data has been saved'.
UIManager has actually a lot of options on this and a lot of messages you can use. UIManager实际上有很多选择,您可以使用很多消息。 Just explore the class and I am sure you will find something that fits your needs. 只是探索课程,我相信您会找到适合您需求的东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.