Does a LABEL really need all these events?

I am in the process of creating a LABEL subclass to use in future SWIFT projects, and I want to make it as reusable as possible.

Looking at the Xojo Label control according the the LR is has all of these events

  • AcceleratorKey
  • Close
  • ConstructContextualMenu
  • ContextualMenuAction
  • DragEnter
  • DragExit
  • DragOver
  • DropObject
  • KeyDown
  • KeyUp
  • MouseDown
  • MouseDrag
  • MouseEnter
  • MouseExit
  • MouseMove
  • MouseUp
  • MouseWheel
  • Open

I don’t see any use except for perhaps these… it is a LABEL after all

  • Close
  • MouseDown
  • MouseUp
  • Open

What does anyone else think? I’m going to be creating similar subclasses for many other macOS controls with the goal being a drag-n-drop framework

Most of those events are inherited, so if you use inheritance in your object structure then it would be hardly any work for Label.

But people might use Labels in unexpected ways. For example I use a Label as a simple and immediate hint and help system, and with a contextual click you can go to the right page in the online help.

1 Like

In Xojo they are all inherited, and to a point also in Swift as most objects are descended from NSView… but the way I’m doing things it requires a few more lines of code for each event… but I have decided to at least include all the mouse related events, but not the Key or Drag ones, the contextual ones are still being noodled on :slight_smile:

Some of those might be specific to using it on Windows

I made a subclass where I use MouseEnter and MouseExit.

I ended up creating

  • MouseEntered
  • MouseExited
  • MouseMoved
  • MouseDragged
  • MouseUp
  • MouseDown

left all the others out at least for now

1 Like

I have one (out of all my code, only one) instance where I used MouseWheel to change the text of a label. This was to let the user select the type of information they would be putting into the adjacent text field. I would have used a drop down menu but there was limited real estate and the user didn’t want anything on the screen blocked by a menu.