Best way to include stack1 in another stack
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Best way to include stack1 in another stack
Hello
Need some help with including separate stacks and cards in a new stack.
For example I have a stack that creates a calendar that picks the day that was clicked on, (in a data grid). That I want to use in another stack as a picker.
Tried "start using stack" but could not make that work also tried copying the objects from one stack to the other one, but I don't want to multiple copies work with.
There is probably an easy way to do this but I haven't been able to find it.
Thanks
Need some help with including separate stacks and cards in a new stack.
For example I have a stack that creates a calendar that picks the day that was clicked on, (in a data grid). That I want to use in another stack as a picker.
Tried "start using stack" but could not make that work also tried copying the objects from one stack to the other one, but I don't want to multiple copies work with.
There is probably an easy way to do this but I haven't been able to find it.
Thanks
Re: Best way to include stack1 in another stack
Hi dntknwjck,
every object is bound to ONE stack, so this is not possible without copying,
if I understood you correctly.
However copying data from one stack (datagrid) to another is a snap!
Best
Klaus
every object is bound to ONE stack, so this is not possible without copying,
if I understood you correctly.
However copying data from one stack (datagrid) to another is a snap!
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 9665
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Best way to include stack1 in another stack
Hi.
If I understand what you are trying to do, the problem is not accessing the controls of one stack from another, it is that certain controls, that is, the table field and the dataGrid, are difficult to access that way. Here is an experiment that you might find useful if you want to try to kluge this. Make two new stacks. Name one "xxx" and the other "yyy". In stack "xxx" make a button and name it "b1". In stack "yyy" make a button and name it "b2".
In the script of btn "b1:
In the script of btn "b2":
Works fine; you get a number every time you click on "b2". Either line above will do the trick.
But from what I said above, it is not easy to click at some loc of either of those two controls. You do not get the response you want. The dataGrid especially only likes direct mouse clicks. It does a lot with that simple action. There are kluges discussed here about ways to fool it.
But you might try your own kluge. Write back if you do.
Craig
If I understand what you are trying to do, the problem is not accessing the controls of one stack from another, it is that certain controls, that is, the table field and the dataGrid, are difficult to access that way. Here is an experiment that you might find useful if you want to try to kluge this. Make two new stacks. Name one "xxx" and the other "yyy". In stack "xxx" make a button and name it "b1". In stack "yyy" make a button and name it "b2".
In the script of btn "b1:
Code: Select all
on mouseUp
set the clipBoardData to random(999)
end mouseUp
Code: Select all
on mouseUp
send "mouseUp" to btn "b1" of stack "xxx"
-- click at the loc of btn "b1" of stack "xxx" -- ANOTHER WAY
answer the clipBoardData
end mouseUpp
But from what I said above, it is not easy to click at some loc of either of those two controls. You do not get the response you want. The dataGrid especially only likes direct mouse clicks. It does a lot with that simple action. There are kluges discussed here about ways to fool it.
But you might try your own kluge. Write back if you do.
Craig
Re: Best way to include stack1 in another stack
Craig
Thanks for the example. That is not exactly what I am trying to do. I guess my original question was not clear.
I have built a calendar using a DataGrid to use as a date picker. At this time I have a main stack and a subStack with the calendar on the subStack.
I know I could rename this and continue on with my project but then I end up with the same code in several places and maintenance becomes a problem.
Is there a way to reuse or import the original subStack into another application?
I know this can be done with script using a script only stack.
I have tried to copy and past but that doesn't work well with the DataGrid haven't tried cloning, but see from some posts that doesn't work well either.
Terry
Thanks for the example. That is not exactly what I am trying to do. I guess my original question was not clear.
I have built a calendar using a DataGrid to use as a date picker. At this time I have a main stack and a subStack with the calendar on the subStack.
I know I could rename this and continue on with my project but then I end up with the same code in several places and maintenance becomes a problem.
Is there a way to reuse or import the original subStack into another application?
I know this can be done with script using a script only stack.
I have tried to copy and past but that doesn't work well with the DataGrid haven't tried cloning, but see from some posts that doesn't work well either.
Terry
-
- VIP Livecode Opensource Backer
- Posts: 9665
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Best way to include stack1 in another stack
Hi.
Why do you have two stacks? Is one a "splash" stack that becomes the executable when making standalones?
As for getting code in one place, accessible from many other places, there are several techniques. These include creating library stacks, using behaviors, or sending certain scripts "to back". These all depend on what you want achieve.
Craig
Why do you have two stacks? Is one a "splash" stack that becomes the executable when making standalones?
As for getting code in one place, accessible from many other places, there are several techniques. These include creating library stacks, using behaviors, or sending certain scripts "to back". These all depend on what you want achieve.
Craig
Re: Best way to include stack1 in another stack
Hi
Used two stacks to develop the calendar and interface. From previous platforms I have used I have been able to import things like this and assumed that to be the case with LiveCode. Appears I was wrong.
Can something like this be put in a library and be reused? If so can you point me to some place that has explanations and examples on how to build and use libraries.
Terry
Used two stacks to develop the calendar and interface. From previous platforms I have used I have been able to import things like this and assumed that to be the case with LiveCode. Appears I was wrong.
Can something like this be put in a library and be reused? If so can you point me to some place that has explanations and examples on how to build and use libraries.
Terry
-
- VIP Livecode Opensource Backer
- Posts: 9665
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Best way to include stack1 in another stack
OK. Whatever. (and I am not being snarky)Used two stacks to develop the calendar and interface.
Certainly you can, though perhaps "import" is not the right term in the LC world.assumed that to be the case with LiveCode. Appears I was wrong.
Exploiting the message hierarchy is the principal native method to set up stacks that allow messages to "funnel" through them, usually "above" or "after" everything else contained in your app and its environs. You can also "insert" a single script, of any kind, "into back", where it, too, will receive messages after everything else does. Further, behaviors are supported in the quest to make LC more object oriented, and these are explicitly designated button or stack scripts that receive messages from other objects that point to them.
In short, yes, you can establish all the tools you need to do what you want.
A question at the most basic level. Do you know how to place, say, a "mouseUp" handler in the card script in such a way that any number of buttons on that card can use that handler? And that each of those buttons can be identified by the overarching handler so that each button can do its own thing?
Craig
Last edited by dunbarx on Tue Mar 03, 2020 2:51 pm, edited 1 time in total.
Re: Best way to include stack1 in another stack
Heya Terry,
To answer what seems like your most likely way to go,
I'm not sure why you wouldn't be able to just set your substack as it's own stack and issue a 'start using stack [your stack]' as you indicated in your first post, unless it was because it was a substack of another stack. Someone that knows better may be able to say for sure.
To answer what seems like your most likely way to go,
check http://livecode.byu.edu/messages/libraries.php
I'm not sure why you wouldn't be able to just set your substack as it's own stack and issue a 'start using stack [your stack]' as you indicated in your first post, unless it was because it was a substack of another stack. Someone that knows better may be able to say for sure.
Re: Best way to include stack1 in another stack
Thanks Bogs, that was exactly what I was looking for.
-
- VIP Livecode Opensource Backer
- Posts: 9665
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Best way to include stack1 in another stack
"Start using", as bogs explicitly mentioned, is how one does this. You can think of stacks "in use" as library stacks. These are placed near the very end of the hierarchy. But it is the hierarchy, and comfort in its use, that you simply must start practicing with.Exploiting the message hierarchy is the principal native method to set up stacks that allow messages to "funnel" through them, usually "above" or "after" everything else contained in your app and its environs.
For the other methods, you need to explore the "insert script" command, and then read a bit about behaviors:
http://lessons.livecode.com/m/4071/l/69 ... a-behavior
This and its related lessons...
Craig
Re: Best way to include stack1 in another stack
Hi,
Still a good example how to do it: Sarah Reichelt's Calendar
Basically, your calendar is a separate stack. You call it:
Now you're in the Calendar stack, and when you're done selecting, do there:
Back at the caller stack, right after the first line at top, you:
Bingo.
Have fun!
Still a good example how to do it: Sarah Reichelt's Calendar
Basically, your calendar is a separate stack. You call it:
Code: Select all
go to stack Calendar as modal
Code: Select all
set the dialogdata to "whatEverYouWantToReturn"
close this window
Code: Select all
put the dialogdata into theDate
Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!
Re: Best way to include stack1 in another stack
Definitely worth looking at, nicely put together.
Re: Best way to include stack1 in another stack (DatePicker)
Thanks to all.
The information from AxWald was the final piece to make this work.
After I get things cleaned up I will post the code. It may be helpful to others.
DtPicker is a calendar Date Picker Example
I forgot how much fun it is to be a "Newbe"
Terry
DtPicker.zip posted 3/10/2020
The information from AxWald was the final piece to make this work.
After I get things cleaned up I will post the code. It may be helpful to others.
DtPicker is a calendar Date Picker Example
I forgot how much fun it is to be a "Newbe"
Terry
DtPicker.zip posted 3/10/2020
- Attachments
-
- DtPicker.zip
- (10.92 KiB) Downloaded 171 times