Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 43 additions & 5 deletions CodenameOne/src/com/codename1/impl/CodenameOneImplementation.java
Original file line number Diff line number Diff line change
Expand Up @@ -5243,13 +5243,18 @@ protected void dispatchNativeMenuCommand(Command cmd) {
if (cmd == null) {
return;
}
if (!cmd.isEnabled()) {
// A disabled Command must not run because its menu item was clicked. The row format
// carries no enabled flag, so the native item is created enabled and stays
// clickable; greying it out as well needs another field and a matching change in
// every native parser. This is the half that prevents the damage.
if (!cmd.isEnabled() || cmd.isDesktopSeparator()) {
// The native item is greyed out too (NativeMenuEncoder.FLAG_ENABLED), but a menu
// published before the command was disabled can still deliver a click.
return;
}
// A check item flips and a radio item becomes the checked one of its group BEFORE the
// command runs, as a native toggle does, so the action reads the new state.
if (cmd.getDesktopRadioGroup() != null) {
cmd.setDesktopChecked(true);
} else if (cmd.isDesktopCheckable()) {
cmd.setDesktopChecked(!cmd.isDesktopChecked());
}
Form current = Display.getInstance().getCurrent();
ActionEvent ev = new ActionEvent(cmd);
if (current != null && formCarriesCommand(current, cmd)) {
Expand Down Expand Up @@ -11124,6 +11129,39 @@ public boolean isNativeTitle() {
public void refreshNativeTitle() {
}

/// The title a desktop port shows in the OS title bar of the main window for a form: the
/// form's title, with the leading `*` Windows and Linux applications use for a document
/// with unsaved changes. A port with its own indicator for that state reads
/// `Form#isDocumentModified()` itself and uses `Form#getTitle()`.
///
/// #### Parameters
///
/// - `f`: the form
///
/// #### Returns
///
/// the title to show, never null
public String getNativeWindowTitle(Form f) {
String t = f.getTitle();
if (t == null) {
t = "";
}
return f.isDocumentModified() ? "*" + t : t;
}

/// Called when a form's document-modified state changes, see
/// `Form#setDocumentModified(boolean)`. The default refreshes the native title, which
/// `#getNativeWindowTitle(Form)` marks.
///
/// #### Parameters
///
/// - `f`: the form
public void documentModifiedChanged(Form f) {
if (f == getCurrentForm()) { //NOPMD CompareObjectsWithEquals
refreshNativeTitle();
}
}

/// Indicates the way commands should be added to a form as one of the ocmmand constants defined
/// in this class
///
Expand Down
Loading