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

Commit e59b702

Browse files
committed
[[ Bug 15565 ]] Fixed create ctrl in card "..."
1 parent 09bbc57 commit e59b702

File tree

6 files changed

+11
-7
lines changed

6 files changed

+11
-7
lines changed

docs/notes/feature-create-in.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Additional forms of create command
2+
- Create <card> in <stack> now works correctly
3+
- You can now create <control> in <card> as well as in <group>

engine/src/card.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class MCCard : public MCObject, public MCMixinObjectHandle<MCCard>
136136
IO_stat loadobjects(IO_handle stream, uint32_t version);
137137

138138
void kfocusset(MCControl *target);
139-
MCCard *clone(Boolean attach, Boolean controls, MCStack *p_parent=nullptr);
139+
MCCard *clone(Boolean attach, Boolean controls, MCStack *p_parent = nullptr);
140140
void clonedata(MCCard *source);
141141
void replacedata(MCStack *source);
142142
Exec_stat relayer(MCControl *optr, uint2 newlayer);

engine/src/cmdsc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ void MCCreate::exec_ctxt(MCExecContext& ctxt)
660660
uint4 parid;
661661

662662
if (!container->getobj(ctxt, parent, parid, True)
663-
|| parent->gettype() != CT_GROUP)
663+
|| (parent->gettype() != CT_GROUP && parent->gettype() != CT_CARD) )
664664
{
665665
ctxt . LegacyThrow(EE_CREATE_BADBGORCARD);
666666
return;

engine/src/exec-interface.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3299,7 +3299,7 @@ void MCInterfaceExecCreateCard(MCExecContext& ctxt, MCStringRef p_new_name, MCSt
32993299
ctxt . SetItToValue(*t_id);
33003300
}
33013301

3302-
MCControl* MCInterfaceExecCreateControlGetObject(MCExecContext& ctxt, int p_type, MCGroup *&r_parent)
3302+
MCControl* MCInterfaceExecCreateControlGetObject(MCExecContext& ctxt, int p_type, MCObject *&r_parent)
33033303
{
33043304
switch (p_type)
33053305
{
@@ -3328,9 +3328,9 @@ MCControl* MCInterfaceExecCreateControlGetObject(MCExecContext& ctxt, int p_type
33283328
}
33293329
}
33303330

3331-
void MCInterfaceExecCreateControl(MCExecContext& ctxt, MCStringRef p_new_name, int p_type, MCGroup *p_container, bool p_force_invisible)
3331+
void MCInterfaceExecCreateControl(MCExecContext& ctxt, MCStringRef p_new_name, int p_type, MCObject *p_container, bool p_force_invisible)
33323332
{
3333-
if (MCdefaultstackptr->islocked())
3333+
if (MCdefaultstackptr->islocked())
33343334
{
33353335
ctxt . LegacyThrow(EE_CREATE_LOCKED);
33363336
return;

engine/src/exec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3120,7 +3120,7 @@ void MCInterfaceExecCreateStack(MCExecContext& ctxt, MCStack *p_owner, MCStringR
31203120
void MCInterfaceExecCreateScriptOnlyStack(MCExecContext& ctxt, MCStringRef p_new_name);
31213121
void MCInterfaceExecCreateStackWithGroup(MCExecContext& ctxt, MCGroup *p_group_to_copy, MCStringRef p_new_name, bool p_force_invisible);
31223122
void MCInterfaceExecCreateCard(MCExecContext& ctxt, MCStringRef p_new_name, MCStack *p_parent, bool p_force_invisible);
3123-
void MCInterfaceExecCreateControl(MCExecContext& ctxt, MCStringRef p_new_name, int p_type, MCGroup *p_container, bool p_force_invisible);
3123+
void MCInterfaceExecCreateControl(MCExecContext& ctxt, MCStringRef p_new_name, int p_type, MCObject *p_container, bool p_force_invisible);
31243124
void MCInterfaceExecCreateWidget(MCExecContext& ctxt, MCStringRef p_new_name, MCNameRef p_kind, MCGroup *p_container, bool p_force_invisible);
31253125

31263126
void MCInterfaceExecClone(MCExecContext& ctxt, MCObject *p_target, MCStringRef p_new_name, bool p_force_invisible);

tests/lcs/core/interface/stack.livecodescript

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ on TestCreateControlInCard
3232
create stack "Temp"
3333

3434
create card "Other"
35+
create card "Other2"
3536

3637
create button "Test" in card "Other"
3738

@@ -40,10 +41,10 @@ end TestCreateControlInCard
4041

4142
on TestCreateControlInStack
4243
create stack "Temp"
44+
create stack "Temp2"
4345

4446
create card "Other" in stack "Temp"
4547

46-
put there is a card "Other"
4748

4849
TestAssert "test if the card was created in the correct stack" , there is a card "Other" of stack "Temp"
4950
end TestCreateControlInStack

0 commit comments

Comments
 (0)