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
]
]
Related
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
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 ?
Is there a shortcut to close all inspector windows ? and if not how I close the window of a selected inspector ?
Basically I accidentally opened over 1000 inspector windows and i want to close them all now because they have occupied the entire GUI and I cant do anything other than closing them on by one. I cant open the world menu or open a new window because they take not only the entire window but also they are always on top.
Bring up the halos [1] on the TaskBarMorph [2] and click the top left halo to delete it from the World.
If two-way halo cycling is enabled in the settings, Alt-click on Mac. Otherwise, Alt-Shift-Click to cycle to the TaskBarMorph through the morphs in front of it.
In your case, your problem is that it's covering the entire screen, so you should be able to click anywhere to bring up the halos.
Then, to actually close the windows, use something like:
World submorphs do: [ :e |
[ (e model model model isKindOf: InspectorNavigator) ifTrue: [ e delete ] ]
on: Error
do: [ ] ]
I tried the following in a Pharo 3.
UITheme inspect.
And then did a World inspect to come to the following.
(World submorphs select:
[ :each | each class = TickingSpecWindow ])
do:
[:insp | insp delete]
You should be more specific in your select if you only want the inspector windows,
explore uses the same class.
I was wondering how feasible is to add some compound elements (nodes) "on the go".
Scenario:
I have a network with nodes from n1...n10 and edges. Depending on the button the user clicks, it redraws my network including nodes inside a compound node.
Example:
When you open the graph, you have n1..n10, without compounds, but when you click on a pre-defined button, my new graph now would be:
A new compound node with n1:n5 inside (parent), and the rest n6:n10 would stay the same (outside compound).
How feasible is it ?
I've tried :
cy.batchData({
"5": {
parent: "n0" // new element I added earlier
}});
to update my element id=5 to have n0 as parent, but it haven't worked.
The main idea is to represent data (graph) with biological insight, where the "new compound area" would be a pathway or a metabolic path (or whatever I want to represent there), one by one, so the visualization won't be a mess.
Thank you.
You can't change the parent field; it's immutable. You may have to remove the elements and add the second (resultant) graph via eles.remove() and cy.add() respectively.
Using Rebol/View 2.7.7, I'm trying to create a card game based on Nick's Rebol tutorial at: http://re-bol.com/rebol.html#section-10.18. What I want to do though is read the cards from the binary file Nick created, discard some of the data, and use it to layout a tableau of cards, 4 rows of 3 columns, with the 2 center card locations not used.
Here's my code:
protect-system
random/seed now
do %cards.r ;--include the binary card data
the-tableau: [
size 320x480 backdrop 0.170.0
style tabstyle image 80x100 teal
style holdplace box 80x100 coal
across
at 30x20 tc1: tabstyle
tc2: tabstyle
tc3: tabstyle return
at 30x130 tc4: tabstyle
tc100: holdplace
tc5: tabstyle return
at 30x240 tc6: tabstyle
tc200: holdplace
tc7: tabstyle return
at 30x350 tc8: tabstyle
tc9: tabstyle
tc10: tabstyle
]
lc: copy []
lc: [tc1 tc2 tc3 tc4 tc5 tc6 tc7 tc8 tc9 tc10]
deck-cards: copy [] ; The deck holds all of the cards from the binary file
deck-cards-num: copy []
deck-cards-color: copy []
lay: layout the-tableau
foreach [card label num color pos] cards [
dimg: load to-binary decompress (card)
append deck-cards dimg ;feel movestyle
throw-away-label: label
append deck-cards-num num
append deck-cards-color color
throw-away-pos: pos
]
random-card: does [pick deck-cards random length? deck-cards]
foreach c lc [set-face get c deck-cards]
view lay
do-events
But this doesn't show the cards at all. I'm not even sure it's reading the correctly? Where is the problem?
Actually you didn't use the random-card function in your for loop at the end... :-)
foreach c lc [get c set-face get c random-card ]
You note that you are not sure if data was loaded correctly...
here is a simple way to find out... just print/probe the TYPE? of that data
dimg: load to-binary decompress (card)
probe type? dimg
In this case it will print out image! in the console... so yep... that's working. :-)
As an added little detail, I noticed you didn't compensate your random for the "back face" image in the card data (which is at its end), so the random-card function should be fixed like so:
random-card: does [pick deck-cards random (length? deck-cards) - 1] ; - 1 since we don't want the back face to be picked.
You only need 'do-events if the event loop is not started.
View/new does not start the event loop .. but View does
I'm not addressing your actual problem though :(
to make the do-events note clear, I added a little answer here so I can add some inline code....
here is an example where you'd want your do-events to be used.
view/new lay ; display the interface right now. (with no cards)
random-card: does [pick deck-cards random (length? deck-cards) - 1] ; - 1 since we don't want the back face to be picked.
; deal cards with a half second delay.
foreach c lc [f: get c set-face get c random-card wait 0.5]
do-events
here, any code you put after 'DO-EVENTS will be executed once all view windows have closed.
which can be things like tmp file cleanup, save on exit, "save changes" dialogs, etc.
additional note:
While building graphics code, its a good habit to place this at the very start of you application:
print " "
It will open up the console, and then any view windows will show up in front of it.
When ready to share, just comment the line and remove any print statements in your code.
this is useful for 3 things:
1) Its usually highly annoying when the console always pops-up over your application while its tracing (print/probe/etc) some stuff after your window opens.
2) This also has the more useful side-effect of showing you if your application quit correctly since the console will ALSO quit when all waits have terminated correctly.
In your original example, if you add the above print, then you'll see that the console never closes, so this means the application is still running with no more application windows listening to events.
3) It also has the advantage that you can terminate the graphic app directly by closing the console window. This effectively closes all windows and waits immediately and shortcuts any "on application quit" code you might have (code after do-events).