Rebol - How can I append text from a text field to a text list? - rebol

I've been exploring the amazing Rebol programming tool. I've run into a problem of trying to append text from a text field into the data of a text-list. My code below adds text to the text-list but changes all previous text to the current one multiplied by how many data entries were already in the text list.
How can I correct this?
REBOL [
Title: "test4"
Version: 1.3.3
Author: "me"
Purpose: {create a list of countries}
]
populate: does[
country: countryField/text
append txtList/data country
show lay
]
lay: layout [
across
text "Enter name of country" black bold
countryField: field
return
across
txtList: text-list
panel [
button "Add" [populate]
button "Delete" [remove back tail txtList/data show lay]
button "Clear" [clear txtList/data show lay]
]
]
view lay

You just need to copy the text:
country: copy countryField/text
For short, without copying a series (a string in this case) you just append the same one multiple times, it is all the same string. When you change it you just change one string but you see it as multiple changes.
Here you can read the detailed explanation:
https://github.com/red/red/wiki/%5BDOC%5D-Why-you-have-to-copy-series-values

Related

vuejs set a layout in js and run that in template

Title sounds a bit weird but let me explain.
I made a component that allows me to generate dynamic input fields based on a json list.
Only some fields I would like to have next to each other and that is not possible in the current construction. So I came up with an idea to make a JSON "layout template" with rows and columns and which ID field belongs where.
For example "layout template":
{
"row": {
field: {id:"ID-FIELD-1",type:"text"}
},
"row": {
field: {id:"ID-FIELD-2",type:"phone"},
field: {id:"ID-FIELD-3",type:"email"}
},
"row": {
field: {id:"ID-FIELD-4",type:"text"}
}
etc...
}
Now I can make a JSON "layout template" and put an "input component" in each field. This "input component" then loops to the correct type of input field. Only this seems a bit too much to go through the input list every time looking for the right type for each field.
So I've been looking for ways in javascript to setup/format the whole template in a "string" like way and have it picked up by Vuejs as if it were a standard ....
Then I dont have to loop the whole field section every time.
I don't know if this is possible or if there are other ways to do this?

Conditionally capturing pre-determined text in one field based on multiple choice selection in another field in REDCap

Problem: How can you capture a pre-determined or static text value based on what choice a user makes from a multiple choice menu on a survey?
Example: Suppose you have the following basic setup:
I have four text statements that correspond to options 1-4 (e.g., "Statement corresponding to Option 1", "Statement corresponding to Option 2", etc.). If the user chooses, say, Option 1 from the sample_options field, then I would like to capture the text value of the pre-prepared statement in the option_statement field. The user should not be able to alter the captured text statement (e.g., maybe hide the field using the #HIDDEN action tag).
Attempt: It seemed like this might be a problem that could be resolved with action tags, namely the #DEFAULT one, but I have been unable to do this. I also thought about trying to use a calculated field instead of a text field for option_statement, but calculated fields must return numeric values:
This seems like a problem that should be somewhat straightforward to tackle, but I have been baffled by just how hard it seems to be to simply capture static text in one field based on a user's selection in another field.
If I understand the question, you want to select a text string from a list of (in this case) 4 options, depending on the user selecting a choice from a radio/dropdown?
Probably the easiest method is to use #CALCTEXT (if you are on a sufficiently recent version), which allows you to conditionally populate a text field, i.e.:
#CALCTEXT(
if([sample_options] = 1, "This is the label for option 1",
if([sample_options] = 2, "This is the label for option 2",
if([sample_options] = 3, "This is the label for option 3",
if([sample_options] = 4, "This is the label for option 4", "This is an else value")
)
)
)
)
But if you do not have #CALCTEXT available to you, you can do this with a #DEFAULT, by constructing another radio field (#HIDDEN if you like) on a separate page or instrument (as #DEFAULT needs the value to exist in the database on page load, and so does not work dynamically on the page), with your four labels as the options with the same choice codes as your [sample_choices] field. For example:
1,This is the label for option 1
2,This is the label for option 2
3,This is the label for option 3
4,This is the label for option 4
And annotate it with:
#DEFAULT='[sample_choice]'
Thus if a user selects 3 for [sample_choice] and proceeds to the page or instrument that has the label field, the #DEFAULT tag will automatically select choice 3 from the label field, which can then be stored in the dataset and piped into an email, onto the page, or whatever.

How to make text strikethrough when hovered in elm (elm-ui)?

Basically I want to make the text strikethrough when hovered. This doesn't work easily with
el [ mouseOver [Font.strike] ] (text "some text")
as it would with
el [ mouseOver [Background.color someColor] ] (text "some other text")
because Font.strike is a Attribute msg whereas Background.color is of type Attr decorative msg
Does anyone konw how to achieve described behavior with something like Font.strike?
I would also accept non elm-ui solutions if not possible otherwise.
Like you already pointed out, mouseOver requires a Attr decorative msg. It uses CSS for the hover (hence the limitations), which takes care of applying the style on mouse over and clears it on mouse out.
For the general case, we have to detect mouse over/out ourselves, using Element.Events. We also need to keep track of this state in our Model. Then we can apply the Font.strike attribute conditionally depending on the model.
We can listen for these events on an Element.el
Events.onMouseEnter Enter
:: Events.onMouseLeave Leave
:: style
, where style is either [ Font.strike ] or [], depending on the model.
Full code and working demo here: https://ellie-app.com/bNjP6CbGrLJa1

dojox.grid.EnhancedGrid losing focus

I have to refresh an Enhanced List as i have a "quick search" input field
that should update the list while you type. It does work fine, until I select one of the result rows. Then I move back to the input field and start typing but at that moment, the focus is lost and after every letter I have to click back to the input field.
Any method I found refreshing the grid sets the focus to the first header
cell. This means of course that my input field
looses focus. I cannot type more than 1 char without refocusing the field
:-(
Any idea how to re-render a grid (or enhanced grid) without changing focus?
gridtoc = new dojox.grid.EnhancedGrid({
id: 'gridtocsearch',
store: storetoc,
structure: layout,
class: 'grid',
align: 'center',
keepSelection: true,
plugins: {
filter: true
}
});
Thanks a lot, Monika
can you try like
keepSelection:false
official document says
keepSelection
Defined by dojox.grid.EnhancedGrid
Whether keep selection after sort, filter, pagination etc.
***************** updated answer*****************
take a look at this jsfiddle
http://jsfiddle.net/bnqkodup/520/

view with drop-down howto

For a view, I need to define a size, a drop-down with data, set its size and get the chosen value for input in some function.
loadGui: func [] [
unview/all
view layout [
Dropd_urls: drop-down (getUrlsEnd Urls)
]
]
What is a logic behind a style or a facet? Define a word, than the facet then the size, alignment and other properties, then a block for on-action? And what about the (getUrlsEnd Urls) that gets evaluated, where should it be placed? If someone could provide a thorough example on the drop-down, it would be great.
And another question. I'm aware of the help system/..., but cannot get useful information about the logic of how to accomplish what was stated above. Where do you go to get to know how to build the view constructs? A howto? Normally, I read the howtos provided by Nick Antonnacio, but there's more to view than what is shown in his documents.
the demo on atronixengineering.com/r3/demo.r has also a dropdown list under widgets. You could generate your dropdown list with compose/deep.
view layout compose/deep [
Dropd_urls: drop-down [
(getUrlsEnd Urls)
]
]
or with different actions depending of the choice of the dropdown list
view layout [
Dropd_urls: drop-down [
"1"
"2"
] on-action [print face/facets/text]
]
did you read Cross Platform App Development with Rebol 3 Saphir ?