Skip to content

Commit

Permalink
Fixing focus handling behavior.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZILtoid1991 committed Feb 11, 2024
1 parent 4c12083 commit 5f72dc5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,8 @@ public class ListView : WindowElement, ElementContainer, TextInputListener {
///Passes mouse click event
public override void passMCE(MouseEventCommons mec, MouseClickEvent mce) {
///TODO: Handle mouse click when in text editing mode
if (state != ElementState.Enabled) return;
if (state != ElementState.Enabled || parent is null) return;
if (!(state & IS_FOCUSED)) parent.requestFocus(this);
//if ((state & TEXTINPUT_EN) && !mce.state)
if (vertSlider) {
const Box p = vertSlider.getPosition();
Expand Down Expand Up @@ -1028,6 +1029,15 @@ public class ListView : WindowElement, ElementContainer, TextInputListener {
break;
}
}
override void focusTaken() {
if (flags & NEW_ITEM_ADD_EDIT) {
removeEntry(selection);
refresh();
}
if (flags & TEXTINPUT_EN) inputHandler.stopTextInput();
flags &= ~IS_FOCUSED;
//super.focusTaken();
}
/**
* When called, the listener should drop all text input.
*/
Expand Down
7 changes: 4 additions & 3 deletions pixelperfectengine/src/pixelperfectengine/concrete/window.d
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,11 @@ public class Window : ElementContainer, Focusable, MouseEventReceptor {
public void requestFocus(WindowElement sender) {
if (focusables.has(sender)) {
try {
if (focusedElement != -1)
focusables[focusedElement].focusTaken();
Focusable f = cast(Focusable)(sender);
focusedElement = focusables.which(f);
const sizediff_t newFocusedElement = focusables.which(f);
if (focusedElement == newFocusedElement) return;
if (focusedElement != -1) focusables[focusedElement].focusTaken();
focusedElement = newFocusedElement;
focusables[focusedElement].focusGiven();
} catch (Exception e) {
debug writeln(e);
Expand Down

0 comments on commit 5f72dc5

Please sign in to comment.