-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How implement event 'lost focus' on IWidget? #22
Comments
Hi - sorry for the long delay in replying. One suggestion would be to do it like this, from termshark: https://github.com/gcla/termshark/blob/master/widgets/filter/filter.go#L241 In short, a callback is set on the edit widget which is invoked when the text changes. I use that to set the background color of the filter, depending on whether what is entered is syntactically valid. Will that work for your use case? Another approach might be to keep a boolean flag that is set when your widget is rendered (via |
Hi @asv - I know it's been a while since you opened this... I thought I'd let you know I implemented a similar feature to this in termshark. Here's a widget that helps track losing or gaining focus: https://github.com/gcla/termshark/tree/streams/widgets/trackfocus. The widget itself keeps track of how it was last rendered, and when that changes (not focus -> focus and vice-versa) issues a callback. Here's an example use of it: https://github.com/gcla/termshark/blob/streams/widgets/streamwidget/streamwidget.go#L639 There's a small catch. Depending on the way you layout widgets, sometimes a gowid app has to call a widget's |
For example, implement content validation for Edit widget.
The text was updated successfully, but these errors were encountered: