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

World: r3wp

[!RebGUI] A lightweight alternative to VID

Graham
19-Apr-2007
[6235x2]
well, not /insert .. perhaps /ins

set 'set-text make function! [
	"Set and show a widget's text attribute."
	face [object!] "Widget"
	text [any-type!] "Text"
	/ins
	/no-show "Don't show"
	/focus
][
	unless string? face/text [exit]
	either all [ ins face/caret ][
		insert skip head face/text face/caret form text
	][	
		insert clear face/text form text
	]
	all [
		face/para
		face/para/scroll: 0x0
		all [face/type = 'area face/pane/data: 0]
	]
	face/line-list: none
	unless no-show [either focus [set-focus face] [show face]]
]
insert skip head face/text max 0 face/caret - 1 form text
Ashley
19-Apr-2007
[6237x2]
Worthy addition, although I'd call it /caret and the following line 
should suffice:

	insert at face/text face/caret form text


Not that 'at treats values less than 0 as head and values greater 
than length of string as tail.
I've also changed clear-text from:

	if f/text ...

to:

	if string? f/text

in light of the issue you had.
Graham
19-Apr-2007
[6239]
good to know about 'at ... does it deal with 'none as well?
Ashley
19-Apr-2007
[6240]
No, but "either all [caret face/caret]" will catch that.
Graham
20-Apr-2007
[6241]
display "" [ a: area "This is a test string" button "dump" [ probe 
a/caret ]] do-events


seems the caret is only set when you tab out of the area.  other 
ways of changing focus such as using the mouse do not  preserve the 
area's caret value
Ashley
20-Apr-2007
[6242]
That's a bug.
Pekr
20-Apr-2007
[6243]
Will menu be corrected? It takes to clicks to open adjacent menu, 
while it should take zero clicks ...
Ashley
20-Apr-2007
[6244]
On the list. (when I get a moment or two I'll actually add this list 
to the Trac Wiki; that approach works better than tickets for me).
Graham
20-Apr-2007
[6245x5]
Until caret handling is fixed, I suggest that set-text/caret insert 
text at the tail if face/caret is none.  Otherwise, you end up erasing 
existing text.
Something like:

set 'set-text make function! [
	"Set and show a widget's text attribute."
	face [object!] "Widget"
	text [any-type!] "Text"
	/caret {insert at cursor position}
	/no-show "Don't show"
	/focus
][
	unless string? face/text [exit]
	insert either all [ caret face/caret ][
			at face/text face/caret 
	][	
		either caret [ tail face/text ][	clear face/text ] 
	] form text
	all [
		face/para
		face/para/scroll: 0x0
		all [face/type = 'area face/pane/data: 0]
	]
	face/line-list: none
	unless no-show [either focus [set-focus face] [show face]]
]
If you have a large left box, how do you then align the following 
widgets so that 'return aligns to the left large widget?
In VID you set a ruler thingy ...
How to programmatically change the date displayed in a calendar widget 
that is currently being displayed?
tried setting the widget/data: now/date and doing an 'init
Ashley
20-Apr-2007
[6250]
Like the set-text change (and code re-factoring).


Not sure about the alignment question, have an example in VID of 
what you're trying to do?

Calenday quetion is easy:

	cal/date: 1-Feb-2006
	poke cal/options 1 1-Feb-2006
	show cal

data is the currently selected date
options/1 the default date
Graham
20-Apr-2007
[6251x3]
That's okay about the alignment .. I just used a panel to do what 
I wanted.
I had a 


calendar widget1 return widget2 and I wanted widget2 to align with 
the right border of the calendar

so now I have

calendar panel blue data [ widget1 return widget2 ]
typo :)

cal/data: 1-Feb-2006
poke cal/options 1 1-Feb-2006
show cal
Ashley
20-Apr-2007
[6254x2]
Note that in your panel example you can make it act like a positioning 
widget with something like:

	panel none data [margin 0x0 area return area]
Remember how we wrapped current-word and caret handling in attempt 
blocks? Well, I've had plenty of caret errors to track down but not 
a single current-word error. Then I recall you had that problem where 
you set face/text to a non-string value ... could the current-word 
problems you experienced be related to that?
Graham
20-Apr-2007
[6256x4]
I don't think so ... but it's hard to remember all of this now.
trap and forget ...
I would have posted the error messge here .. let me reset my search 
parameters for Altme
here it was:

make object! [
    code: 303
    type: 'script
    id: 'expect-arg
    arg1: 'find
    arg2: 'series
    arg3: [series! port! bitset!]

    near: [s: any [all [s: find/reverse str s next s] head str] set [ns]]
    where: 'current-word
]
Ashley
20-Apr-2007
[6260]
I'm trapping and writing these errors out to %rebgui.log, does your 
log file contain any current-word errors? (search for "word trap" 
if there are lots of entries)?
Graham
20-Apr-2007
[6261x2]
just lots of 

19-Apr-2007/18:18:20+12:00 Caret trap password origin: 2x2
margin: 2x2
indent: 0x0
tabs: 0
wrap?: false
scroll: 0x0
but then I had already wrapped an attempt around those
Ashley
20-Apr-2007
[6263]
But at least you haven't had a current-word error since installing 
the latest builds. It's just that looking at the current-word function, 
it's only called from one place, and you already have to have focus 
and caret with a valid string before the function is called, i.e. 
I can't see how it *could* fail [now]. I'll probably leave the attempt 
in there for a couple more builds/weeks, but if it traps no errors 
I'll remove it as fixed.
Graham
21-Apr-2007
[6264x2]
select-row is not working?


>> display "" [ t: table options ["row" left .99] data [ "a" "b" 
][ print face/selected ] button "select" [ t/sele
ct-row 1 ]] do-events
the action is not invoked when I use the button
Ashley
21-Apr-2007
[6266]
Missed that one when I converted actions over to on-*. Change:

	unless no-action [action self]

in %table.r to:

	unless no-action [action/on-click self]

Text-list is OK.
Graham
21-Apr-2007
[6267x5]
ok.
typo ... in tour.r unziped should be unzipped
Has anyone got a good ellipsis button to use to indicate that one 
can bring up a directory requestors etc eg. button ".."
I was thinking of using the eye symbol in the webdings ie. "N"
Doesn't look too out of place
there is the magnifying glass "L"
Ashley
21-Apr-2007
[6272]
That caret "bug" you were having may not be the same one I'm fixing. 
Try this:

	display "" [
		f: field
		field
		button [print f/caret]
	]


f/caret is correctly set when you tab or mouse click out of the field. 
It is not set when you click the button. So far, so good. Do you 
have a different usage case that causes a problem?
Graham
21-Apr-2007
[6273x4]
well, the caret is not set if you click inside f
you can click inside f, and type and the caret values does not change
for me, it only gets set on a tab
so mouse clicking out of the field does not set the caret
Ashley
21-Apr-2007
[6277]
1) The caret value is set when the widget loses focus. The original 
purpose was to remember where you were in the text if you left it. 
Updating the caret after every keystroke is a bit extreme. If you 
want to get the caret position in a face that currently has focus 
just use "index? system/view/caret"


2) When I run the code given above I click in the first field, then 
the second, then press the button to have a "1" displayed. You don't 
get the same result?


3) Dictionary symbol. Have you tried the "book" symbol? Wingding 
"&" I think.
Graham
21-Apr-2007
[6278x5]
I primarily want to click inside a body of text to place the caret, 
and then push a button to insert a block of text
2.  Usually I find that the caret does not change at all.
I suspect it would not be particularly overkill to track the caret 
on every keystroke ... editors do it all the time.
otherwise text insertion is going to be hit and miss
it violates gui principles if you claim the ability to insert at 
the caret, but it inserts elsewhere
Ashley
21-Apr-2007
[6283]
click inside a body of text to place the caret, and then push a button 
to insert a block of text

 Ah, got it. The solution is simple then. We add a line to set-text 
 (after the string? test) that reads:


 all [view*/caret none? face/caret face/caret: index? view*/caret]
Graham
21-Apr-2007
[6284]
let me try :)