r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[View] discuss view related issues

Anton
9-Oct-2006
[5754]
Starting at the top:
system/view/event-port/awake --->  system/view/wake-event
Gabriele
9-Oct-2006
[5755x2]
wake-event behaves differently when there is a popup open
it returns true (which makes wait [] return) when hide-popup has 
been called
Anton
9-Oct-2006
[5757x2]
Yes, wake-event calls system/view/popface/feel
inform calls show-popup which creates your new pop-face.
Rebolek
12-Oct-2006
[5759]
simple and almost useless tool :)

do http://bolek.techno.cz/reb/webtext.r
Anton
12-Oct-2006
[5760]
Hmm not bad.
Gregg
12-Oct-2006
[5761]
Very cool bolek! With a few more fields for control of color and 
gradients, and the ability to save as an image, I would suggest it 
for inclusion as a Desktop entry with things like Font-lab and such.
Rebolek
12-Oct-2006
[5762]
Good idea, Gregg, I'll look into it! Hm, guess I should finish Texture-lab 
also... :)
Gregg
12-Oct-2006
[5763]
Yes! That was a way cool app.
Rebolek
12-Oct-2006
[5764]
Updated version of TextureLab - do http://bolek.techno.cz/reb/texture-lab.r
Louis
14-Oct-2006
[5765x6]
What could be causing this error. I get it whither I encap or not.

** Script Error: trans-date has no value
** Where: switch
** Near: forall args [
    val: first args
    switch/default type?/word val [
        pair! [append pairs val]
        integer...


So far as I know I haven't touched this part of the script this is 
found in.
Is there anything wrong with this:


style dater txt bold right [trans-date/text: copy (to-string now/date)] 
48x24
or this:


        dater "T-Date:" trans-date: field 80x24 (to-string now/date) feel 
        [
            engage: func [face action event][
                if action = 'up [

                    lv-dat: request-date/date/offset (now/date) 315x30
                    if lv-dat <> none [
                        trans-date/text: copy to string! lv-dat
                        show trans-date
                    ]
                ]
            ]
            ;trans-date/text: copy (to-string now/date)
            show trans-date
        ]
I really have trouble debugging view scripts, especially long complicated 
ones.  Usually, I make only one of two changes, then run the script. 
That way I know what part of the code is actually causing the error. 
This time, however, after making some changes I had to take care 
of an unrelated problem before I had opportunity to test the script. 
Now several months later, I finally have time to test, but ... I 
can't remember what the last changes were.
Has anyone written a "How to debug REBOL/View" doc?
Are there any debug tools?
Graham
14-Oct-2006
[5771x3]
Your error says 'trans-date is not defined.
trans-date is defined in your layout .. so therefore must be reference 
before the layout is created if you have that error.
without seeing the relevant part it may be that the problem is that 
your style references a field which has not been defined yet.
Louis
14-Oct-2006
[5774x2]
Thank, Graham. I'm looking.
I was using the wrong version of the SDK.
Anton
14-Oct-2006
[5776]
Louis,  you're doing something strange there with the SHOW in the 
feel.
Louis
14-Oct-2006
[5777x2]
I couldn't find the error because it didn't exist in the code. :>)
Anton, you mean because there are two shows?
Anton
14-Oct-2006
[5779x2]
No, when you specify a feel spec block, you're actually doing something 
like this:

	feel: make feel [
1)		engage: func ...
2)		show trans-date
	]
You are making an object.

On line 1) you are replacing the value of the 'engage word with a 
new function value of your own.

On line 2) you are simply doing some code. So this code executes 
at the time of the object creation.
Louis
14-Oct-2006
[5781]
OK, how do I do it right?
Anton
14-Oct-2006
[5782x5]
Looking at the code I assume what you want to do is initialise the 
text facet and make sure it's shown the first time the display is 
shown.
Well, you shouldn't have to SHOW the first time - that should be 
taken care of by VIEW or the SHOW that shows your whole layouted 
face in which you have your dater and trans-date field.
So that just leaves setting the text correctly the first time. And 
you are already doing that.
So just remove those two final lines from the feel spec.
By the way, to-string already makes a copy.
>> same? (to string! str: "example") str
== false
Louis
14-Oct-2006
[5787]
I'm learning a lot tonight. Thanks.
Anton
14-Oct-2006
[5788]
Welcome.
Robert
15-Oct-2006
[5789]
I have a question WRT changing the text of a shown label. I use a 
way where the layout of my GUI is done at startup-time once. Now 
I need to change the text of some labels at run-time and I don't 
want to do the following:
	- name each label that needs to be updated.

 - write a function that changes the TEXT word and shows the widget


I would like to use a word in the initial context that keeps a reference 
to the text (or function returning the text) which gets reevaluated 
if a SHOW is used.


Do I have to write an own style that supports this or is there a 
simpler way?
Henrik
15-Oct-2006
[5790x2]
an easy way is to keep all labels in a panel and then traverse the 
pane and set the label texts on a label.
if your panel consists of multiple different types of faces, you 
can filter on 'style
Anton
15-Oct-2006
[5792x4]
How about this:
data: ["hello" "there" "robert"]

spec: copy []
foreach string data [
	append spec compose [label 100 (string)]
]

view window: layout append spec [
	btn "change original strings" [
		insert clear data/1 "happy"
		insert clear data/2 "to be"
		insert clear data/3 "changed"
		show window
	]
]
You have to make sure the initial labels are large enough for your 
longest strings. Of course we can stylize label so that it resizes 
automatically, but maybe you don't need that.
Henrik's way can be helped using SET-FACE, I think. (I haven't used 
this feature yet.)
Have a look in svv/vid-styles/panel/access 'set-face*
Robert
15-Oct-2006
[5796x3]
Anton, ah the insert clear method... I missed this one. I think that's 
the way to go. I'll check this out. Thanks.
Hmm... one more. Let's I have:
	label-text: "The current value is ?"

and I know want to change the ? dynamically. After first replacement 
the ? is gone. So I need some way to keep the source version. Or 
first insert the source version, than replace and show.
Oh man... to many typos (I cut my right finger):
- Let's say I have
- know = now
Gregg
15-Oct-2006
[5799]
; Something like this maybe?

REBOL []

texts: [
    EN [
       lbl-1 "Hello"
       lbl-2 "Goodbye"
    ]
    DE [
       lbl-1 "Hallo"
       lbl-2 "Aufwiedersehen"
    ]
]

lang: 'EN
res: func [id] [texts/:lang/:id]

good-ID?: func [id] [find texts/:lang id]

has-res-ID?: func [face] [
    all [
        find first face 'res-ID
        word? face/res-ID
        good-ID? face/res-ID
    ]
]

re-show: func [face] [
    foreach f face/pane [
        if has-res-ID? f [
            set-face f res f/res-ID
        ]    
    ]
    show face
] 


lay: layout [
    text 100 with [res-ID: 'lbl-1]
    text 100 with [res-ID: 'lbl-2]
    btn "English" [lang: 'EN  re-show lay]
    btn "Deutsch" [lang: 'DE  re-show lay]
]

re-show lay
view lay
Louis
15-Oct-2006
[5800]
tr "Rp/US$:" exchange-rate: field 270x24 feel [
            exchange-rate/text: exchange-rat
            show exchange-rate
        ]


The above code loads exchange-rat into exchange-rate/text when the 
script loads.  But after saving data it appears to be empty. How 
can exchange-rate/text be forced to persistently show its contents?
Louis
16-Oct-2006
[5801x3]
I changed it to this:

        tr "Rp/US$:" exchange-rate: field 270x24 

        feel [exchange-rate/text: exchange-rat: (read %exchange-rate.txt)
            show exchange-rate 
            (write %exchange-rate.txt exchange-rat) 
        ]

But it still doesn't work.
What I want is:


1. The exchange rate to be saved in a file, so that it will always 
be loaded upon start the script.

2. The exchange rate to remain in the field through each loop of 
view.

3. And, of course, I want to be able to change the exchange rate 
if needed.


Seems like it should be a common easy thing to do, but it eludes 
me.
Perhaps it would be clearer to say that I don't want to have to manually 
enter the exchange rate for each record.