@@ -41,3 +41,16 @@ events and request _interrupt_.
|
||||
----
|
||||
include::{snippets}/TerminalUiSnippets.java[tag=exitingfromloop]
|
||||
----
|
||||
|
||||
== Modal View
|
||||
|
||||
`TerminalUI` supports having one active modal view. Modal view is placed
|
||||
on top of all other views and takes all input events.
|
||||
|
||||
[source, java, indent=0]
|
||||
----
|
||||
include::{snippets}/TerminalUiSnippets.java[tag=uimodal]
|
||||
----
|
||||
|
||||
NOTE: As views should not directly know anything about `TerminalUi` and
|
||||
interface `ViewService` exposes modal related functions.
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.springframework.shell.component.message.ShellMessageBuilder;
|
||||
import org.springframework.shell.component.view.TerminalUI;
|
||||
import org.springframework.shell.component.view.TerminalUIBuilder;
|
||||
import org.springframework.shell.component.view.control.BoxView;
|
||||
import org.springframework.shell.component.view.control.DialogView;
|
||||
import org.springframework.shell.component.view.event.EventLoop;
|
||||
import org.springframework.shell.component.view.event.KeyEvent.Key;
|
||||
import org.springframework.shell.geom.HorizontalAlign;
|
||||
@@ -111,4 +112,19 @@ class TerminalUiSnippets {
|
||||
// end::uirun[]
|
||||
}
|
||||
|
||||
class SampleUiModal {
|
||||
|
||||
// tag::uimodal[]
|
||||
TerminalUI ui;
|
||||
|
||||
void sample() {
|
||||
DialogView dialog = new DialogView();
|
||||
// set modal
|
||||
ui.setModal(dialog);
|
||||
// clear modal
|
||||
ui.setModal(null);
|
||||
}
|
||||
// end::uimodal[]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user