Class: Accessibility::Highlighter
- Inherits:
-
NSWindow
- Object
- NSWindow
- Accessibility::Highlighter
- Defined in:
- lib/accessibility/highlighter.rb
Overview
A screen highlighter for debugging. When you initialize a highligter object it will highlight the given bounds on the screen.
Highligter objects can have their colour configured at initialization, and can also have a timeout to automatically stop displaying.
Instance Method Summary collapse
-
#initialize(bounds, opts = {}) ⇒ Highlighter
constructor
A new instance of Highlighter.
-
#stop ⇒ self
Tell the highlighter to stop displaying.
Constructor Details
#initialize(bounds, opts = {}) ⇒ Highlighter
Returns a new instance of Highlighter.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/accessibility/highlighter.rb', line 23 def initialize bounds, opts = {} colour = opts[:colour] || opts[:color] || NSColor.magentaColor bounds.flip! # we assume the rect is in the other co-ordinate system initWithContentRect bounds, styleMask: NSBorderlessWindowMask, backing: NSBackingStoreBuffered, defer: true setOpaque false setAlphaValue 0.20 setLevel NSStatusWindowLevel setBackgroundColor colour setIgnoresMouseEvents true setFrame bounds, display: false makeKeyAndOrderFront NSApp if opts.has_key? :timeout Dispatch::Queue.new(queue_id).after opts[:timeout] do self.stop end end end |
Instance Method Details
#stop ⇒ self
Tell the highlighter to stop displaying.
51 52 53 |
# File 'lib/accessibility/highlighter.rb', line 51 def stop close end |