Thraka/SadConsole

Left click on a TextBox causes both EditModeEnter and EditModeExit events to trigger.

RychuP opened this issue · 2 comments

As per title.

I took a quick look through the source:

  • Setting DisableKeyboard to true triggers EditModeExit, false triggers EditModeEnter.
  • OnLeftMouseClicked sets this property to false. This would trigger EditModeEnter.
  • Later on in OnLeftMouseClicked, the text box is set to the focused object. This should ultimately trigger Focused(), which sets DisableKeyboard to true. This will trigger EditModeExit.

It seems odd to me that Focused() is setting DisableKeyboard to true; I would expect it to set false, so as to trigger the edit mode enter event. Even if it did, though, it looks like it would end up triggering EditModeEnter twice on click; once in OnLeftMouseClick, and once in focus. Having it in both places, makes sense in theory, because the control can be focused without the use of the mouse and it should probably still trigger EditModeEnter; but probably there should be some sort of guard on one or more of these property setters to prevent firing the event multiple times in a row?

Edit mode was removed in v10 so this bug is technically fixed 😁