-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: context menu disable on click (#3973)
* docs: context menu disable on click * address review comments * remove admonition * minor edit --------- Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com> Co-authored-by: Jouni Koivuviita <jouni@vaadin.com>
- Loading branch information
1 parent
9f464d5
commit c3f119d
Showing
2 changed files
with
55 additions
and
0 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
38 changes: 38 additions & 0 deletions
38
src/main/java/com/vaadin/demo/component/contextmenu/ContextMenuDisableOnClick.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,38 @@ | ||
package com.vaadin.demo.component.contextmenu; | ||
|
||
import com.vaadin.demo.DemoExporter; // hidden-source-line | ||
import com.vaadin.flow.component.contextmenu.ContextMenu; | ||
import com.vaadin.flow.component.contextmenu.MenuItem; | ||
import com.vaadin.flow.component.html.Div; | ||
import com.vaadin.flow.component.html.Paragraph; | ||
import com.vaadin.flow.router.Route; | ||
|
||
@Route("context-menu-disable-on-click") | ||
public class ContextMenuDisableOnClick extends Div { | ||
|
||
public ContextMenuDisableOnClick() { | ||
Paragraph paragraph = new Paragraph(); | ||
paragraph.setText("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."); | ||
add(paragraph); | ||
|
||
ContextMenu menu = new ContextMenu(paragraph); | ||
// tag::snippet[] | ||
MenuItem summarize = menu.addItem("Summarize with AI"); | ||
summarize.setDisableOnClick(true); | ||
// end::snippet[] | ||
summarize.setKeepOpen(true); | ||
summarize.addClickListener(event -> { | ||
// Simulate long-running operation | ||
try { | ||
Thread.sleep(2000); | ||
} catch (InterruptedException e) { | ||
// ignore | ||
} | ||
summarize.setEnabled(true); | ||
paragraph.setText("Lorem ipsum dolor sit amet."); | ||
}); | ||
} | ||
|
||
public static class Exporter extends DemoExporter<ContextMenuDisableOnClick> { // hidden-source-line | ||
} // hidden-source-line | ||
} |