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
21-Apr-2007
[6269x3]
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
[6284x2]
let me try :)
make object! [
    code: 311
    type: 'script
    id: 'invalid-path
    arg1: 'caret
    arg2: none
    arg3: none

    near: [all [view*/caret none? face/caret face/caret: index? view*/caret] 
        insert either all
    ]
    where: 'show-text
]
Ashley
21-Apr-2007
[6286x2]
Probably needs to read:


 all [caret view*/caret none? face/caret face/caret: index? view*/caret]

If this works the whole thing can be refactored a bit.
Error looks like the widget hasn't got a caret aatribute.
Graham
21-Apr-2007
[6288x3]
Nope, not working.
It's inserting at the head of the face and not at the caret after 
clicking on the text in the area
head of face/text
Ashley
21-Apr-2007
[6291x3]
Let me try here ...
Update set-text with:

	unless string? face/text [exit]
	insert either caret [
		if all [
			none? face/caret
			face = view*/focal-face
			view*/caret
		] [face/caret: index? view*/caret]
		either face/caret [at face/text face/caret] [tail face/text]
	][
		clear face/text
	] form text
Then run the following:

	display "" [
		f: field
		field
		button [set-text/caret f "X"]
	]


Click in f, type some text, click or arrow to the middle of the text 
and press the button. Text is inserted at caret.
Graham
21-Apr-2007
[6294x2]
not for me
still requires a tab to set the caret position correctly
Ashley
21-Apr-2007
[6296x4]
Hmm, maybe there are other changes at play here. Let me upload latest 
build ...
Build uploaded.
So, running the text above I click into f, type "ab", press the left 
arrow key once and then the button. What I see is an "X" inserted 
between letters "a" and "b" (i.e. "aXb") with the cursor positioned 
between the "a" and "X". Is this what you see? Is this "correct"?
Or do you expect the cursor to be positioned between the letters 
"X" and "b"?
Graham
21-Apr-2007
[6300]
doesn't matter
Ashley
21-Apr-2007
[6301]
Huh?
Graham
21-Apr-2007
[6302x4]
but if you now move the cursor to the head of the text, and click 
button, it still inserts as before.
I guess the caret should be at the end of the inserted text
and this mirrors what happens when you type
the face/caret is not being updated when you click inside the text
Ashley
21-Apr-2007
[6306]
OK, Mk III

	unless string? face/text [exit]
	either caret [
		if all [
			face = view*/focal-face
			view*/caret
		] [face/caret: index? view*/caret]
		either face/caret [
			insert at face/text face/caret form text
			view*/caret: at face/text face/caret + length? form text
			face/caret: index? view*/caret
		] [insert tail face/text form text]
	] [insert clear face/text form text]
Graham
21-Apr-2007
[6307x2]
sorry ...
no better
Ashley
21-Apr-2007
[6309]
I type "ab" ArLeft and press button to get "aX|b"
the ArLeft, ArLeft and press button to get "X|aXb"

Is this what you get?
Graham
21-Apr-2007
[6310x2]
No
let me resync a new directory
PeterD
21-Apr-2007
[6312x2]
I get aXXb
|aXXa
Graham
21-Apr-2007
[6314x2]
a|Xb
|aXXb
Ashley
21-Apr-2007
[6316]
Ah, my fault. I didn't sync the above change.
Graham
21-Apr-2007
[6317x2]
I did
I put mark III in