view with drop-down howto - rebol

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 ?

Related

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

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

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

div component in form generation (by schema) not working as expected

In a sample project, I placed the "Flexbox Wrapper" code sample here (picking from the drop-down list)
The code below is meant to create 2 columns for the children form components of cheese options and toppings:
...preceding code...
{
"component": "div",
"class": "flex-wrapper",
"children": [
....
However it shows both as one column (see image attached.) I have absolutely no other styling asides the header link pointing to the default snow.min.css at by CDN.
This is so basic, surprised it's not working as documented. Is there any implicit step I have missed to get this working?
Also not sure why the heading, represented by an 'h3' component in the schema, is appearing as a different font.

Remove button faces

Hi all.
I want to know that how can I remove two button face with a button.
I tried this:
gui: [
en: button "English" remove [en es]
es: button "Spanih" remove [en es]
]
And than I have to append new buttons.
View engine models GUI interface as a tree of objects; each node in that tree is called a face, and each field of that face is called a facet.
Two facets, parent and pane, interlink a face with its parent node and its child nodes, respectively. So, by that theory, to remove a button is to remove a button face from a pane of its parent:
view [button "Poof!" [probe select take face/parent/pane 'text]]
This, however, is a bit limited approach. The removed face is detached from View tree and can no longer be used unless you reattach the face! object with the same specification back to the pane. It might be more useful to simply disable a button, or to render it invisible for the time being. enabled? and visible? facets can achieve just that:
view [
title "Face flags example"
below
toggle "Toggle" [foo/enabled?: not foo/enabled?]
foo: button "Switch" disabled [bar/visible?: not bar/visible?]
bar: base red
]
You can adapt this approach to the task at hand. As I understand, you want to offer mutually exclusive localization options; drop-list might be a good fit for that:
view [drop-list data ["en" "es"]]
You can try this:
Red [Needs: View]
view [
en: button "English" [remove find face/parent/pane en]
es: button "Spanish" [
remove find face/parent/pane en
remove find face/parent/pane es
]
]

elm-bootstrap with elm-css don't get along well?

I'm trying to use both elm-css and elm-bootstrap in the same project but it looks like they don't get along well.
What I like about elm-css is that it's a drop-in replacement for the html core modules, and by just using other imports and composing your main view with toUnstyled, you get all the goodies.
{ view = view >> toUnstyled, ... }
But elm-bootstrap functions don't expect to receive the elm-css styled elements so we must remove the styles, cluttering my code with calls to toUnstyled everywhere, like i.e.
Table.td [] [ toUnstyled <| text "Hi!" ]
I could live with that, but the real show stopper appears when we need to add attributes like i.e.
Table.td [ Table.cellAttr <| class "text-center" ]
[ toUnstyled <| text "Hi!" ]
This only works if class is from core Html module, not elm-css. It would work if we could use toUnstyled <| class "text-center, but this function (for attributes) is "missing" in elm-css (the quotes are there because I'm not sure if it even makes sense to have it, fromUnstyled exists though).
So, is toUnstyled for attributes really missing?, are there any other viable options for having what both libs offer?
In terms of options, what should be done to elm-bootstrap to make it accept elm-css styled attributes? should it be a wrapper lib that calls to toUnstyled before each call to elm-bootstrap? Any thoughts?