-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial infrastructure for keyboard focus and events.
- Loading branch information
Showing
40 changed files
with
389 additions
and
433 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
....jsycamore.api/src/main/java/com/io7m/jsycamore/api/keyboard/SyKeyboardFocusBehavior.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright © 2023 Mark Raynsford <code@io7m.com> https://www.io7m.com | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | ||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
|
||
package com.io7m.jsycamore.api.keyboard; | ||
|
||
/** | ||
* A specification of how keyboard focus may traverse a component. | ||
*/ | ||
|
||
public enum SyKeyboardFocusBehavior | ||
{ | ||
/** | ||
* The component can directly receive focus, and will pass focus to its | ||
* children if the focus traversal is continued. | ||
*/ | ||
|
||
RECEIVES_FOCUS_AND_CONTINUES_TRAVERSAL, | ||
|
||
/** | ||
* The component can directly receive focus, but will not pass focus to its | ||
* children if the focus traversal is continued. | ||
*/ | ||
|
||
RECEIVES_FOCUS_AND_STOPS_TRAVERSAL, | ||
|
||
/** | ||
* The component cannot directly receive focus, but will pass focus to its | ||
* children if the focus traversal is continued. | ||
*/ | ||
|
||
IGNORES_FOCUS_AND_CONTINUES_TRAVERSAL, | ||
|
||
/** | ||
* The component cannot directly receive focus, and will not pass focus to its | ||
* children if the focus traversal is continued. | ||
*/ | ||
|
||
IGNORES_FOCUS_AND_STOPS_TRAVERSAL; | ||
|
||
/** | ||
* @return {@code true} if this behavior implies that a component will | ||
* receive focus | ||
*/ | ||
|
||
public boolean receivesFocus() | ||
{ | ||
return switch (this) { | ||
case RECEIVES_FOCUS_AND_CONTINUES_TRAVERSAL -> true; | ||
case RECEIVES_FOCUS_AND_STOPS_TRAVERSAL -> true; | ||
case IGNORES_FOCUS_AND_CONTINUES_TRAVERSAL -> false; | ||
case IGNORES_FOCUS_AND_STOPS_TRAVERSAL -> false; | ||
}; | ||
} | ||
|
||
/** | ||
* @return {@code true} if this behavior implies that a component will pass | ||
* focus to its children | ||
*/ | ||
|
||
public boolean continuesFocusTraversal() | ||
{ | ||
return switch (this) { | ||
case RECEIVES_FOCUS_AND_CONTINUES_TRAVERSAL -> true; | ||
case RECEIVES_FOCUS_AND_STOPS_TRAVERSAL -> false; | ||
case IGNORES_FOCUS_AND_CONTINUES_TRAVERSAL -> true; | ||
case IGNORES_FOCUS_AND_STOPS_TRAVERSAL -> false; | ||
}; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...re.api/src/main/java/com/io7m/jsycamore/api/keyboard/SyKeyboardFocusableReadableType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright © 2023 Mark Raynsford <code@io7m.com> https://www.io7m.com | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | ||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
|
||
package com.io7m.jsycamore.api.keyboard; | ||
|
||
import com.io7m.jattribute.core.AttributeReadableType; | ||
|
||
/** | ||
* The readable interface to objects that involve keyboard focus. | ||
*/ | ||
|
||
public interface SyKeyboardFocusableReadableType | ||
{ | ||
/** | ||
* @return The keyboard focus behavior | ||
*/ | ||
|
||
AttributeReadableType<SyKeyboardFocusBehavior> keyboardFocusBehavior(); | ||
} |
31 changes: 31 additions & 0 deletions
31
....jsycamore.api/src/main/java/com/io7m/jsycamore/api/keyboard/SyKeyboardFocusableType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright © 2023 Mark Raynsford <code@io7m.com> https://www.io7m.com | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | ||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
|
||
package com.io7m.jsycamore.api.keyboard; | ||
|
||
import com.io7m.jattribute.core.AttributeType; | ||
|
||
/** | ||
* The interface to objects that involve keyboard focus. | ||
*/ | ||
|
||
public interface SyKeyboardFocusableType | ||
extends SyKeyboardFocusableReadableType | ||
{ | ||
@Override | ||
AttributeType<SyKeyboardFocusBehavior> keyboardFocusBehavior(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.