Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

[[ Bug 22843 ]] Implement modal/sheet without waiting #7404

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
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
19 changes: 11 additions & 8 deletions docs/dictionary/command/go.lcdoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Synonyms: open

Type: command

Syntax: go [{visible | invisible}] [to] <card> [of <stack>] [{as <mode> |in [a] new window|in <window>}]
Syntax: go [{visible | invisible}] [to] <card> [of <stack>] [{as <mode> [without waiting]|in [a] new window|in <window>}]

Syntax: go [{visible | invisible}] [to] {first | prev[ious]| next | last | any} [marked] [<card>]

Expand Down Expand Up @@ -48,6 +48,9 @@ set the defaultFolder to tStackFolder
go stack "somethingElse.livecode"
-- "somethingElse" being the name of a stack file in the same folder

Example:
go stack "EditRecord" as modal without waiting

Parameters:
card:
Any card reference. Cards can be described by their name, number, or ID
Expand All @@ -60,13 +63,13 @@ command opens the main stack of the specified stack file.

mode (enum):

- editable window
- palette
- modal dialog box
- modeless dialog box
- sheet dialog box - appears in <defaultStack(property)>
- drawer - appears in <defaultStack(property)>, centered at left
side if there's room
- toplevel: editable window
- palette
- modal: dialog box
- modeless: dialog box
- sheet: dialog box - appears in <defaultStack(property)>
- drawer: appears in <defaultStack(property)>, centered at left
side if there's room


window:
Expand Down
19 changes: 11 additions & 8 deletions docs/dictionary/command/modal.lcdoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Name: modal

Type: command

Syntax: modal <stack>
Syntax: modal <stack> [without waiting]

Summary:
Opens a <stack> as a <modal dialog box>.
Expand All @@ -19,6 +19,9 @@ modal stack "Custom Answer Dialog"
Example:
modal stack x of stacksToPresent

Example:
modal stack "NewRecord" without waiting

Parameters:
stack:
Any stack reference.
Expand Down Expand Up @@ -56,13 +59,13 @@ are sent regardless of the setting of the <lockMessages> <property>.
If the stack is already displayed as a modal dialog box, the <modal>
<command> does not close and reopen it.

The <modal> <command> pauses the running <handler> until the
<modal dialog box> is dismissed (usually by clicking a button in the
<modal dialog box>). To <return> information to the <handler> about
which <button(keyword)> was clicked, in the <button(object)|button's>
<script>, set a <global|global variable> or <custom property>. After the
<dialog box> is dismissed, the <handler> can query this <variable> or
<property> and act accordingly.
Unless the without waiting clause is used the <modal> <command> pauses
the running <handler> until the <modal dialog box> is dismissed (usually
by clicking a button in the <modal dialog box>). To <return> information
to the <handler> about which <button(keyword)> was clicked, in the
<button(object)|button's> <script>, set a <global|global variable> or
<custom property>. After the <dialog box> is dismissed, the <handler> can
query this <variable> or <property> and act accordingly.

Modal dialog boxes cannot be resized or edited. To edit a modal dialog
box, use the topLevel <command> to display it in an <editable window>.
Expand Down
19 changes: 11 additions & 8 deletions docs/dictionary/command/sheet.lcdoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Name: sheet

Type: command

Syntax: sheet <stack> [in <parentStack>]
Syntax: sheet <stack> [in <parentStack>] [without waiting]

Summary:
Displays a <stack> as a <sheet|sheet dialog box>.
Expand All @@ -19,6 +19,9 @@ sheet stack "myFilePickerStack"
Example:
sheet me in stack "project1"

Example:
sheet stack "ColorPicker" without waiting

Parameters:
stack:
Any stack reference.
Expand Down Expand Up @@ -51,13 +54,13 @@ want to prevent the close <message|messages> from being sent; the open
<message|messages> are sent regardless of the setting of the
<lockMessages> <property>.

The <sheet> <command> pauses the running <handler> until the
<sheet(command)> is dismissed (usually by clicking a button in the
<sheet(command)>). To <return> information to the <handler> about which
<button(keyword)> was clicked, in the <button(object)|button's>
<script>, set a <global|global variable> or <custom property>. After the
<dialog box> is dismissed, the <handler> can query this <variable> or
<property> and act accordingly.
Unless the without waiting clause is used the <sheet> <command> pauses
the running <handler> until the <sheet(command)> is dismissed (usually
by clicking a button in the <sheet(command)>). To <return> information
to the <handler> about which <button(keyword)> was clicked, in the
<button(object)|button's> <script>, set a <global|global variable> or
<custom property>. After the <dialog box> is dismissed, the <handler> can
query this <variable> or <property> and act accordingly.

Attempting to open a sheet from within another sheet displays the second
<stack> as a <modal dialog box> instead.
Expand Down
4 changes: 4 additions & 0 deletions docs/notes/bugfix-22843.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# New `without waiting` clause added to modal, sheet and go commands

The new clause allows for the opening of modal and sheet dialogs without the
handler waiting for the stack to be closed before continuing.
2 changes: 1 addition & 1 deletion engine/src/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2804,7 +2804,7 @@ void MCButton::openmenu(Boolean grab)
menu->menuset(menuhistory, rect.height >> 1);
}

menu->openrect(rel, (Window_mode)menumode, NULL, WP_DEFAULT, OP_NONE);
menu->openrect(rel, (Window_mode)menumode, NULL, WP_DEFAULT, OP_NONE, false);
menu->mode_openasmenu(t_did_grab ? sptr : NULL);

// MW-2014-03-11: [[ Bug 11893 ]] Make sure we don't do anything to a stack panel.
Expand Down
4 changes: 2 additions & 2 deletions engine/src/cardlst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void MCCardlist::gorel(int2 offset)
if (sptr != MCdefaultstackptr && MCdefaultstackptr->hcstack())
MCdefaultstackptr->close();
sptr->setcard(cards->card, False, False);
sptr->openrect(sptr->getrect(), WM_LAST, NULL, WP_DEFAULT, OP_NONE);
sptr->openrect(sptr->getrect(), WM_LAST, NULL, WP_DEFAULT, OP_NONE, false);
MCdefaultstackptr = sptr;
}

Expand Down Expand Up @@ -249,7 +249,7 @@ void MCCardlist::godirect(Boolean start)
if (sptr != MCdefaultstackptr && MCdefaultstackptr->hcstack())
MCdefaultstackptr->close();
sptr->setcard(cards->card, False, False);
sptr->openrect(sptr->getrect(), WM_LAST, NULL, WP_DEFAULT, OP_NONE);
sptr->openrect(sptr->getrect(), WM_LAST, NULL, WP_DEFAULT, OP_NONE, false);
MCdefaultstackptr = sptr;
}

Expand Down
14 changes: 13 additions & 1 deletion engine/src/cmds.h
Original file line number Diff line number Diff line change
Expand Up @@ -1769,6 +1769,7 @@ class MCGo : public MCStatement

MCChunk *widget;
Chunk_term direction;
bool m_wait_while_open;
public:
MCGo() :
background(nil),
Expand All @@ -1780,7 +1781,8 @@ class MCGo : public MCStatement
visibility_type(kMCInterfaceExecGoVisibilityImplicit),
thisstack(False),
widget(nil),
direction(CT_BACKWARD)
direction(CT_BACKWARD),
m_wait_while_open(false)
{
;
};
Expand Down Expand Up @@ -1898,6 +1900,7 @@ class MCSubwindow : public MCStatement
MCExpression *properties;
protected:
Window_mode mode;
bool m_wait_while_open;
public:
MCSubwindow()
{
Expand All @@ -1921,6 +1924,7 @@ class MCTopLevel : public MCSubwindow
MCTopLevel()
{
mode = WM_TOP_LEVEL;
m_wait_while_open = false;
}
};

Expand All @@ -1930,6 +1934,7 @@ class MCModal : public MCSubwindow
MCModal()
{
mode = WM_MODAL;
m_wait_while_open = true;
}
};

Expand All @@ -1939,6 +1944,7 @@ class MCModeless : public MCSubwindow
MCModeless()
{
mode = WM_MODELESS;
m_wait_while_open = false;
}
};

Expand All @@ -1948,6 +1954,7 @@ class MCOption : public MCSubwindow
MCOption()
{
mode = WM_OPTION;
m_wait_while_open = false;
}
};

Expand All @@ -1957,6 +1964,7 @@ class MCPalette : public MCSubwindow
MCPalette()
{
mode = WM_PALETTE;
m_wait_while_open = false;
}
};

Expand All @@ -1966,6 +1974,7 @@ class MCPopup : public MCSubwindow
MCPopup()
{
mode = WM_POPUP;
m_wait_while_open = false;
}
};

Expand All @@ -1975,6 +1984,7 @@ class MCPulldown : public MCSubwindow
MCPulldown()
{
mode = WM_PULLDOWN;
m_wait_while_open = false;
}
};

Expand All @@ -1984,6 +1994,7 @@ class MCSheet : public MCSubwindow
MCSheet()
{
mode = WM_SHEET;
m_wait_while_open = true;
}
};

Expand All @@ -1994,6 +2005,7 @@ class MCDrawer : public MCSubwindow
MCDrawer()
{
mode = WM_DRAWER;
m_wait_while_open = false;
}
};

Expand Down
34 changes: 27 additions & 7 deletions engine/src/cmdss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,19 @@ Parse_stat MCGo::parse(MCScriptPoint &sp)
(PE_GO_NOMODE, sp);
return PS_ERROR;
}

if (mode == WM_MODAL || mode == WM_SHEET)
{
if ((sp.skip_token(SP_SUGAR, TT_PREP, PT_WITHOUT) == PS_NORMAL) &&
(sp.skip_token(SP_MOVE, TT_UNDEFINED, MM_WAITING) == PS_NORMAL))
{
m_wait_while_open = false;
}
else
{
m_wait_while_open = true;
}
}
}
else
{
Expand Down Expand Up @@ -748,7 +761,7 @@ void MCGo::exec_ctxt(MCExecContext &ctxt)
else if (window != nil)
MCInterfaceExecGoCardInWindow(ctxt, cptr, *t_window, visibility_type, thisstack == True);
else
MCInterfaceExecGoCardAsMode(ctxt, cptr, mode, visibility_type, thisstack == True);
MCInterfaceExecGoCardAsMode(ctxt, cptr, mode, visibility_type, thisstack == True, m_wait_while_open);
}

MCHide::~MCHide()
Expand Down Expand Up @@ -1490,6 +1503,13 @@ Parse_stat MCSubwindow::parse(MCScriptPoint &sp)
return PS_ERROR;
}
}
else if ((mode == WM_MODAL || mode == WM_SHEET) &&
(sp.skip_token(SP_SUGAR, TT_PREP, PT_WITHOUT) == PS_NORMAL) &&
(sp.skip_token(SP_MOVE, TT_UNDEFINED, MM_WAITING) == PS_NORMAL))
{
m_wait_while_open = false;
}

return PS_NORMAL;
}

Expand Down Expand Up @@ -1558,9 +1578,9 @@ void MCSubwindow::exec_ctxt(MCExecContext &ctxt)
case WM_PALETTE:
case WM_MODAL:
if (*optr_name != nil)
MCInterfaceExecOpenStackByName(ctxt, *optr_name, mode);
MCInterfaceExecOpenStackByName(ctxt, *optr_name, mode, m_wait_while_open);
else
MCInterfaceExecOpenStack(ctxt, (MCStack *)optr, mode);
MCInterfaceExecOpenStack(ctxt, (MCStack *)optr, mode, m_wait_while_open);
break;
case WM_SHEET:
case WM_DRAWER:
Expand All @@ -1572,9 +1592,9 @@ void MCSubwindow::exec_ctxt(MCExecContext &ctxt)
if (mode == WM_SHEET)
{
if (*optr_name != nil)
MCInterfaceExecSheetStackByName(ctxt, *optr_name, *t_parent_name, thisstack == True);
MCInterfaceExecSheetStackByName(ctxt, *optr_name, *t_parent_name, thisstack == True, m_wait_while_open);
else
MCInterfaceExecSheetStack(ctxt, (MCStack *)optr, *t_parent_name, thisstack == True);
MCInterfaceExecSheetStack(ctxt, (MCStack *)optr, *t_parent_name, thisstack == True, m_wait_while_open);
}
else
{
Expand Down Expand Up @@ -1630,9 +1650,9 @@ void MCSubwindow::exec_ctxt(MCExecContext &ctxt)
}
}
if (optr == nil)
MCInterfaceExecDrawerStackByName(ctxt, *optr_name, *t_parent_name, thisstack == True, t_pos, t_align);
MCInterfaceExecDrawerStackByName(ctxt, *optr_name, *t_parent_name, thisstack == True, t_pos, t_align, m_wait_while_open);
else
MCInterfaceExecDrawerStack(ctxt, (MCStack *)optr, *t_parent_name, thisstack == True, t_pos, t_align);
MCInterfaceExecDrawerStack(ctxt, (MCStack *)optr, *t_parent_name, thisstack == True, t_pos, t_align, m_wait_while_open);
}
break;
}
Expand Down
4 changes: 2 additions & 2 deletions engine/src/exec-dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ void MCDialogExecCustomAnswerDialog(MCExecContext &ctxt, MCNameRef p_stack, MCNa
added = True;
}

t_success = ES_NORMAL == t_stack->openrect(t_parent_stack->getrect(), p_sheet ? WM_SHEET : WM_MODAL, p_sheet ? t_parent_stack : nil, WP_DEFAULT, OP_NONE);
t_success = ES_NORMAL == t_stack->openrect(t_parent_stack->getrect(), p_sheet ? WM_SHEET : WM_MODAL, p_sheet ? t_parent_stack : nil, WP_DEFAULT, OP_NONE, true);

if (added)
MCnexecutioncontexts--;
Expand Down Expand Up @@ -746,7 +746,7 @@ void MCDialogExecCustomAskDialog(MCExecContext& ctxt, MCNameRef p_stack, MCNameR
added = True;
}

t_success = ES_NORMAL == t_stack->openrect(t_parent_stack->getrect(), p_as_sheet ? WM_SHEET : WM_MODAL, p_as_sheet ? t_parent_stack : nil, WP_DEFAULT, OP_NONE);
t_success = ES_NORMAL == t_stack->openrect(t_parent_stack->getrect(), p_as_sheet ? WM_SHEET : WM_MODAL, p_as_sheet ? t_parent_stack : nil, WP_DEFAULT, OP_NONE, true);

if (added)
MCnexecutioncontexts--;
Expand Down
2 changes: 1 addition & 1 deletion engine/src/exec-ide.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void MCIdeExecShowMessageBox(MCExecContext& ctxt)

// MW-2007-08-14: [[ Bug 3310 ]] - "show message box" toplevels rather than palettes
if (mb != NULL)
mb->openrect(ctxt . GetObject()->getstack()->getrect(), WM_PALETTE, NULL, WP_DEFAULT, OP_NONE);
mb->openrect(ctxt . GetObject()->getstack()->getrect(), WM_PALETTE, NULL, WP_DEFAULT, OP_NONE, false);
}

////////////////////////////////////////////////////////////////////////////////
Loading