简体   繁体   中英

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.

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. Just explore the class and I am sure you will find something that fits your needs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM