All Projects â†’ todar â†’ VBA-Userform-EventListener

todar / VBA-Userform-EventListener

Licence: MIT License
🎉 A very easy way to add event listeners to a userform.

Programming Languages

vba
158 projects

Projects that are alternatives of or similar to VBA-Userform-EventListener

tsee
Typed EventEmitter implemented with tsargs
Stars: ✭ 22 (+29.41%)
Mutual labels:  events, eventlistener
Compact-Unity-Events
UnityEvents drawer with collapsing, reordering and compact UX
Stars: ✭ 41 (+141.18%)
Mutual labels:  events
THREE.Interactive
Fast and simple interaction manager for three.js for enabling mouse and touch events on 3D objects
Stars: ✭ 49 (+188.24%)
Mutual labels:  events
observable ish
Observable state and events for browser and Flutter.
Stars: ✭ 26 (+52.94%)
Mutual labels:  events
2019.djangocon.us
⛵ The DjangoCon US 2019 conference website
Stars: ✭ 18 (+5.88%)
Mutual labels:  events
timber-ruby
🌲 Great Ruby logging made easy.
Stars: ✭ 155 (+811.76%)
Mutual labels:  events
node-google-calendar
Simple node module that supports Google Calendar API
Stars: ✭ 76 (+347.06%)
Mutual labels:  events
event
The implementation of the pattern observer
Stars: ✭ 45 (+164.71%)
Mutual labels:  events
cute
An event-centric publisher/subscribe model for objects inspired by the Qt framework
Stars: ✭ 37 (+117.65%)
Mutual labels:  events
keycloak-session-restrictor
Simple event-listener for Keycloak which restricts the current user sessions to one (last one wins) only. Demo purposes only!
Stars: ✭ 48 (+182.35%)
Mutual labels:  events
library-php
WIP: A comprehensive Domain-Driven Design example with problem space strategic analysis and various tactical patterns.
Stars: ✭ 73 (+329.41%)
Mutual labels:  events
node-await-event-emitter
await events library like EventEmitter
Stars: ✭ 19 (+11.76%)
Mutual labels:  events
devevents-web
🦄 An awesome Vue.js front-end for dev.events.
Stars: ✭ 35 (+105.88%)
Mutual labels:  events
burns
Manage your application's events without writing spaghetti code
Stars: ✭ 86 (+405.88%)
Mutual labels:  events
certificates
🎓 Generate event certificates easily
Stars: ✭ 50 (+194.12%)
Mutual labels:  events
networkdays
Networkdays functions ... including `networkdays` excel like function with no dependencies (no NumPy)
Stars: ✭ 22 (+29.41%)
Mutual labels:  events
ngx-stop-propagation
✋ Stop propagation for everyday events with Angular directives 🎩
Stars: ✭ 13 (-23.53%)
Mutual labels:  events
Klendario
A Swift wrapper over the EventKit framework
Stars: ✭ 44 (+158.82%)
Mutual labels:  events
vcenter-event-broker-appliance
The VMware Event Broker Appliance Fling enables customers to unlock the hidden potential of events in their SDDC to easily create event-driven automation.
Stars: ✭ 120 (+605.88%)
Mutual labels:  events
Quizzie
Open Sourced Quiz Portal which can be used for any event / competition with a custom leaderboard.
Stars: ✭ 31 (+82.35%)
Mutual labels:  events

VBA Userform EventListener

A very easy way to add event listeners to a userform.

Buy Me A Coffee

Getting Started

Importing or copying both EventListenerEmitter.cls and EventListenerItem.cls is required in order to work!

Here is a basic template, simply add this to a userform.

Private WithEvents Emitter As EventListenerEmitter

Private Sub UserForm_Activate()
    Set Emitter = New EventListenerEmitter
    Emitter.AddEventListenerAll Me
End Sub

That's it, now you can start listening for events!

Listening for the events

You can listen for all events in one event handler Emitter_EmittedEvent or each individual controls events. see the example below.

' EXAMPLE SHOWING A BASIC WAY OF DOING A HOVER EFFECT
Private Sub Emitter_EmittedEvent(Control As Object, ByVal EventName As EmittedEvent, EventParameters As Collection)
    ' Select statements are really handy working with these events in this way.
    Select Case True
        ' Change color when mouseover, for a fun hover effect :)
        Case EventName = MouseOver And TypeName(Control) = "CommandButton"
            Control.BackColor = 9029664

        ' Don't forget to change it back!
        Case EventName = MouseOut And TypeName(Control) = "CommandButton"
            Control.BackColor = 8435998
    End Select
End Sub

You can also listen just to specific events as well.

Private Sub Emitter_Focus(Control As Object)
    ' CHANGE BORDER COLOR FOR TEXTBOX TO A LIGHT BLUE
    If TypeName(Control) = "TextBox" Then
        Control.BorderColor = 16034051
    End If
End Sub

Private Sub Emitter_Blur(Control As Object)
    ' CHANGE BORDER COLOR BACK TO A LIGHT GREY
    If TypeName(Control) = "TextBox" Then
        Control.BorderColor = 12434877
    End If
End Sub

Or you can listen to specific events on specific controls

Private Sub Emitter_CommandButtonMouseOver(CommandButton As MSForms.CommandButton)
    CommandButton.Backcolor = 9029664
End Sub

Private Sub Emitter_CommandButtonMouseOut(CommandButton As MSForms.CommandButton)
    CommandButton.Backcolor = 8435998
End Sub

Note

This is in the early stages, so feel free to use it as you wish. Currently, the events emitted are pretty simple: Click, DoubleClick, MouseOver, MouseOut, MouseMove, MouseDown, and MouseUp.

As I have time I'll be adding more events and seeing if I have any needed improvements.

Feel free to do a pull request if you added to it or improved it in any way!

Also, I've posted this code on codereview. Feel free to make suggestions or improvements there as well!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].