Example #1
0
func (slct *Select) focusResponse() xevent.FocusOutFun {
	f := func(X *xgbutil.XUtil, ev xevent.FocusOutEvent) {
		if !ignoreFocus(ev.Mode, ev.Detail) {
			slct.Hide()
		}
	}
	return xevent.FocusOutFun(f)
}
Example #2
0
func (c *Client) handleFocusOut() xevent.FocusOutFun {
	f := func(X *xgbutil.XUtil, ev xevent.FocusOutEvent) {
		if ignoreFocus(ev.Mode, ev.Detail) {
			return
		}
		c.Unfocused()
	}
	return xevent.FocusOutFun(f)
}
Example #3
0
func (inp *Input) focusResponse() xevent.FocusOutFun {
	f := func(X *xgbutil.XUtil, ev xevent.FocusOutEvent) {
		if !ignoreFocus(ev.Mode, ev.Detail) {
			if inp.canceled != nil {
				inp.canceled(inp)
			}
			inp.Hide()
		}
	}
	return xevent.FocusOutFun(f)
}
Example #4
0
func (msg *Message) focusResponse() xevent.FocusOutFun {
	f := func(X *xgbutil.XUtil, ev xevent.FocusOutEvent) {
		if !ignoreFocus(ev.Mode, ev.Detail) {
			// We only want to lose focus if enough time has elapsed since
			// the message was shown. Otherwise, we might get some weird
			// events that cause us to hide prematurely...
			elapsed := time.Duration(time.Since(msg.lastShow).Nanoseconds())
			if elapsed/time.Millisecond >= 100 {
				msg.Hide()
			} else {
				// Otherwise, we need to reacquire focus.
				msg.bTop.Focus()
			}
		}
	}
	return xevent.FocusOutFun(f)
}