How to create button to another stack - Livecode - livecode

I want to create button to another stack with code
I have two stack.And Stacks name is "AA" and "BB"
I want to create button in stack "BB" from stack "AA" with my code
on createDigits
create button "test" of stack "BB"
end createDigits
Results: It's create in stack name "AA" and this error message:

Here's one way to do what you want:
on createDigits
set the defaultStack to "BB"
create button "test"
end createDigits

What Mark said.
The "create" command only works on the current card. You therefore have to navigate to that card in order to use the command. Mark used the "defaultStack" command to navigate to the target stack. You could also:
lock screen.
go stack "BB".
create button "test".
go back
That sort of thing.
Craig Newman

Related

How do LiveCode developers simulate multiple open documents from a standard template?

We need to create a text-editor type app that can open multiple text windows at the same time.
The windows should all use the same stack layout.
Is it possible to open one stack several times as if the stack were a template or "stationery"?
If so, then we could inject empty text into the text field on openStack to create a new blank text editor document using the stack as a template.
If the user wanted to open an existing text file, then we could put URL "file://xyz.txt" into field "Text Editor" of stack "the new text editor window"
This would be conceptually like the old Mac Classic idea of "Stationery" documents which were unchangeable, but when a user double-clicked on the document in the Finder it would open in a new window, and be called "Untitled #1".
We seem to remember there was once a setting in LiveCode to save a sub-stack as a "template" so that it could be used to display several identical windows.
After googling and searching through the LiveCode UI and Dictionary the only thing we found was
templateStack
If we were to use templateStack then we would have to build an entire stack programmatically, which defeats the simplicity of the LiveCode programming paradigm.
Are we approaching this wrong?
How do LiveCode developers simulate multiple open documents from a standard template?
The only workaroud which we had was to create a substack as a template, keep the template hidden, and then when we need a new text editor window we would need to:
Create a new totally empty stack
For each item in the template stack...
Create a duplicate item in the new text editor window.
Are we on the wrong track?
You could use "clone" as follows.
(This is not a 'simulation' but one way to use template stacks.)
local templatePath="/Users/admin/myTemplates"
on mouseUp
lock screen
-- clone from file
put templatePath & "/mytemplate.livecode" into longPath
clone stack longPath
-- # or clone from an open stack:
-- clone stack "mytemplate"
put 1 into J
repeat while there is a stack ("copy_"&J)
add 1 to J
end repeat
put ("copy_"&J) into newName
set name of it to newName -- named but not yet saved!
set title of stack newName to (newName & " (not yet saved)")
go stack newName
put URL ("file:" & templatePath & "/myNew.txt") into fld "mainEdit"
unlock screen
end mouseUp

Problems in substack

I create main stack and Substack, also I create a button in sub stack for performing find a word in scrolling field(the scrolling field is main stack).
If coded as
on mouseUp
find "Work" in field "text"--Here "text" is a scrolling field placed in main stack
end mouseUp
This code for button placed in Substack. why it's not working? is it any alternative way
You need to tell where the field is:
on mouseUp
find "Work" in field "text" on stack "mainstack" -- your stack's name, or use stack id XXXX
end mouseUp

How to create custom expandable dialog using ControlsFX

I want to create the same dialog as the one created when using Dialogs.showException(), but instead of showing the stacktrace, I want to show my custom pre-formatted text. The functionality that I want is the Details button behavior.
What I want is this:
But not with the printed stacktrace.
What I have tried is to create my own Throwable, populate it with StackTraceElement objects(filled with the the text that I need) and overwrite the getStackTrace() method to return the populated array. The problem is that the stack trace is displayed from the point where the exception is thrown so the text that I need is shown at the bottom of the expanded pane.
ControlsFX is an open source project.
The source of the Exception Dialog is available here. I'm a ControlsFX committer, so ping me if you need more information.

hardcoded string “Button”, should use #string resource

I am new in Android app development and using Java language.
My problem is every time I make a TextView or Button there is a triangle with the exclamation mark below them.
and when I click it I saw a message saying:
hardcoded string “Button”, should use #string resource
I have two activities, in my main activity there is a Button that when you click it you will go in second activity.
But when I go to my main.java to make a code for the button. There's always the above shown error. I think the eclipse can't find the id of my button and same for my TextView they have same error message.
Here is the code I made:
Button b = FindViewById(R.id.button1);
I also add:
Button b = (Button) FindViewById(R.id.button1);
I am using the latest eclipse classic and ADT august issue. The platform is Android 4.1 API 16.
You shouldn't hardcode the "text" on the widgets use the strings resources ie., strings in the strings.xml to set the text. Declare the "text" you want to display as a string in strings.xml and access it using #string/your_string_name in the layout file.
Notice the id of the button, which is rounded in red. You have to use this id when you want to call it in a method, for an example
Button b = (Button) FindViewById(R.id.button1);
Furthermore, check whether your graphical layout matches with the image I have provided.
Just try your code again with these changes.
Your main.java would look like this.
I am a newbie too, but I believe I got this. So basically what's happening here, java wants you to put your hardcodes in string.xml. so that when accessing it, you will use the given methods below before:
.
But this is how it should be.
Let's start by string.xml
Then come back to your activity_main.xml

Watir : How do we capture the subitems displayed by doing mouseover on a particular item

I am trying to work with mouseover on a particular Item in my application by using the following command
{
ie.text_field(:xpath, "//a[contains(text(),'Deal')]").fire_event('onmouseover')
}
On doing mouseover on a item, two subitems are displayed.
Is there any way to capture the sub items which are part of the Item by doing mouseover with which we can report that our test is pass or fail.
Please suggest.
Additional Information :
If we take example,On the StackOver flow page, If i do mouseover on my name, i get a window where i see activity, privileges, Logout and other stuff. This is really what i was looking for. Is there a way to capture the items displayed on the window on doing mouseover.
I also tried to capture the subitems with the following :
{
text=ie.text_field(:xpath, "//a[contains(text(),'Deal')]").fire_event('onmouseover')
puts(text.inspect)
}
On doing this "text" value is displayed as 'nil'.
My general tactic for such things is a combination of using IRB and the IE Developer tool, or Firebug.
using IRB, type out (or cut and paste) the watir statement to fire the onmouseover command to the proper element on the page.
Then have the developer tool rescan the DOM (there's a little refresh icon you can click) The use the tool to point to an element to point to one of the items in the stuff exposed by the onmouseover. Using the info from that, you can then figure out how to address those elements to get the text from the proper div, etc.
If I do that here to the info that opens up when I float the mouse over my name I can find out that it is a table of class "profile-recent-summary" Furthermore I can then look at the way the table is made up and see for example that the 'today' reputation value is in the second cell on that row.. The row also has the text 'reputation' in it.. so
browser.table(:class, 'profile-recent-summary').row(:text, /reputation/).cell(:index, 2).flash
Should flash the cell I want (index might be 1 if using firewatir or webdriver) I can then replace the .flash with something else like .text if I want to get the text from that cell (which is actually inside a link that sits in the cell)..
without seeing your code, I would 'inspect' the element that you are trying to verify and when_present (text) assert that its true

Resources