Skip to content

Ignore Mouse Clicks, Fade Time Parameter, Future Feature Ideas #1

@orchetect

Description

@orchetect

Great code, nice and simple! Was a nice springboard to work from, getting a HUD notification system working.

I would suggest in class ASHUD that the init() be made private init() to enforce its singleton nature.

Also, add window.ignoresMouseEvents = true to ASHUD.init() otherwise the HUD window can gain focus if the user clicks on it.

Some additional poking around I did with the code:

  • I spent some time and added a fadeTime enum [.defaultDuration, .noFade, .withDuration(Double)] and added it as a parameter to func showHUD so you can easily set a fade-out duration with a default of 0.2 seconds. Fun!
  • I also did a bit of housekeeping and added min/max constraints on the delay time and fade time so they can't be less than zero or more than 5 seconds.
  • I also upgraded the code to Swift 3.

Future ideas:

  • Would be cool to add image support (by way of NSImage passed as a parameter or a user-created image enumeration) to the notifications instead of just text!
  • A queuing manager/system when there are two or more showHUD calls in a very short amount of time (ie: if a notification is called before a previous one has disappeared)

Sorry, I'm a bit new to github and don't know how to contribute with pull requests. But I really appreciate your work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions