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

World: r3wp

[View] discuss view related issues

Henrik
24-Sep-2009
[9166x3]
oops
scroll-panel with [var: 'a]
but when you do that, there is no global word set. it can still be 
useful however, if you desire to recognize a face using different 
means, like traversing a pane for a specific face.
amacleod
24-Sep-2009
[9169]
good to know
Graham
24-Sep-2009
[9170]
Must be a VID thing.  Rebgui doesn''t do this AFAIK
Henrik
24-Sep-2009
[9171]
this is done in the LAYOUT function. good one to study:

source layout
Maxim
24-Sep-2009
[9172]
face/var !!! OMG never knew this.... hehe

amacleod,    there's always stones unturned in REBOL even for us 
advanced users ;-)
Anton
25-Sep-2009
[9173]
I reckon you did know this,. Maxim, but you just forgot about because 
it's not needed so much.

What I do, which is more simple and direct, is just compare face 
with the word I previously set it to, eg:

	my-scroll-panel: scroll-panel

and later in the event handler just

	if face = my-scroll-panel [...]


This is just comparing two object references for equality, which 
is more fundamental and doesn't need any facility of VID.
amacleod
25-Sep-2009
[9174]
Thanks, I'll try that too Anton.


I was not able to gfet Henricks suggestion to work when placing the 
event handler in the main program...it only worked when placed in 
the seperate scroll-panel.r file.
Maxim
25-Sep-2009
[9175]
I always setup stuff in the object directly using the with block. 
I was just amazed that after so long, such a feature is still unknown 
to me.  :-)
Anton
25-Sep-2009
[9176]
Eh? You really ought not to have to modify the scroll-panel.r file. 
That's just going to cause problems for you down the line, because 
you are forking. You should be able to override the default scroll-panel 
feel in your user code. Just let me know what you're trying to do 
with that and I'll show how.
amacleod
25-Sep-2009
[9177]
Anton, I had the same worry about forking....

this addition/change to scroll-panel.r works: 

detect: func [face event][
	if event/type = 'alt-down [	
		if face/var = 'my-scroll-panel [ print "hello"]
	]
	event
]

But this addition to global handler does not: 

alt-detect: func [face event][
	if event/type = 'alt-down [	
		if face/var = 'my-scroll-panel [ print "hello"]
	]
	event
]
insert-event-func :alt-detect

get error on face/var
Anton
26-Sep-2009
[9178]
Yes, probably because not all faces in the system are VID faces. 
A VID face is an extension of system/standard/face with several facets 
added, including VAR.

If the event handler came across a non-VID face, then face/var is 
an invalid path.

So you see, this is an example of why using this method to identify 
a face is more brittle.
You should better use:

	face = my-scroll-panel

to determine identity of a face.
amacleod
26-Sep-2009
[9179]
Anton, Your method is not working for me:

alt-event: func [face event] [
	if event/type = 'alt-down [ print "alt-click"
		if face = my-scroll-panel [print "face name = my-scroll-panel"]
		]
	event
]
insert-event-func :alt-event


I get "alt-click" but I do not get true for 'if face = my-scroll-panel'


I tried 'my-scroll-panel (word) and "my-scroll-panel" (quotes") also....
Anton
26-Sep-2009
[9180x2]
Aha, I know what's probably happening. The scroll-panel contains 
a number of subfaces in a face hierarchy. You are probably not clicking 
on the scroll-panel face, but on one of its subfaces (which are laid 
on top of it, event-wise). If you look at scroll-panel.r, near the 
bottom of the rebol header, you will see the face hierarchy, with 
the two scrollers, the CROP-BOX and the SUBFACE inside the crop-box. 
The SUBFACE covers most of the area of the scroll-panel, and the 
two scrollers take some from the sides.

You can test this idea by giving the scroll-panel an edge, then alt-clicking 
on the edge. You should get a positive identification then. But of 
course, this is probably not very useful to you. What (I assume) 
you will need to do is, given a face, find out if it is inside a 
scroll-panel (or inside a particular scroll-panel of yours). This 
is a little bit complicated, but I have done most of that coding 
already for  mouse roll-wheel scrolling. (See scroll-wheel-handler.r, 
and demo-scroll-wheel-handler.r for how to use it.)
Basically, you will want to make your own "right-click-handler.r", 
just copying scroll-wheel-handler.r's code and modifying the event 
type that is checked for to 'alt-down. Scroll-wheel-handler checks 
for an Anton-extended VID flag, SCROLL-WHEEL, to determine which 
face should handle the event. So I might also advise you define your 
own VID flag to indicate that a face handles alt-click, maybe call 
it simply ALT-DOWN like the event that triggers it, or CONTEXT-MENU-ACTIVE, 
or whatever you're doing. Then make sure that the faces you want 
to respond to your "right-click-handler.r" are flagged with this 
new flag.
That's all, simple!
amacleod
26-Sep-2009
[9182]
I think I see what you are saying, but...
Sounds like more than I want to tackle right now...

I think I'm going to stick with hacking up scroll-panel.r (since 
it seems to work)...the whole app feels like a hacked mess anyway 
so when R3 is ready I'll rewrite it for R3...Where I hope alot of 
these problems will not exist..

Thank you for the help
Graham
26-Sep-2009
[9183]
why not just follow the face up to its parent until you hit the scroll 
panel and then compare then?
amacleod
26-Sep-2009
[9184]
not sure how to go about that..
Graham
26-Sep-2009
[9185]
doesn't each face have a value for parent-face ?
Anton
27-Sep-2009
[9186x3]
That's exactly what I'm doing in scroll-wheel-handler.

Starting with the face clicked on, I climb up to the parent-face 
iteratively until I find an ancestor of the face which is a scroll-panel.
(or until there is no parent-face, which means we are at a top-level 
window face.)
amacleod, I thought all that complication would make you pause. And 
fair enough. I should say though that I've done the scroll-wheel-handler 
in the most proper way I can. It seems a pity not to take advantage 
of its structure. Anyway, it would be nice if you could say what 
you want to handle alt-click for. I'm still not sure why you want 
it. If that's clear to me, then I could probably make the new handler 
for you pretty quickly, as I'm more familiar with my code, obviously.
Henrik
27-Sep-2009
[9189x2]
Incidentally, the VID Extension Kit has a lot of functions to help 
in these situations for finding a specific face.

To for example find the window a face sits in:

root-face face
if you look at the source, the file vid-funcs.r contains most of 
these functions.
BenBran
29-Sep-2009
[9191]
Hello All,

I'm working with events but I'm stuck. Any help is appreciated. here 
is the code:

rebol [	title: event testing]
lo: [
	text 100x100 "Hello" 

  edge [size: 25x25 color: 255.0.0 effect: 'bevel]				;; <--edge set 
  here works
		feel [
			engage: func [face action event] [
				if event/type = 'down [
					face/color: 0.200.0
					show face
				]
				if event/type = 'up [
					face/color: 0.0.200
					show face
				]
			]
			over: func [face into pos] [
				if equal? into True [						;; 

     face/edge: [size: 25x25 color: 0.255.0 effect: 'bevel] 	;; <-- edge 
     changed here
					probe face/edge					;; 
					print into						;; 
					show face						;; <-- doesn't render
				]								;; 
				if equal? into False [						;; 

     face/edge: [size: 25x25 color: 0.0.255 effect: 'bevel] 	;; <-- edge 
     changed here
					probe face/edge					;; 
					print into						;; 
					show face						;; <-- doesn't render
				]								;; 
			]
			detect: func [face event] []
			redraw: func [face action offset] []
		]
]
view layout lo
Steeve
29-Sep-2009
[9192x2]
replace the lines where:
>>face/edge: [...]
by
>> face/edge: make face/edge [...]
face/edge is an object, not a block
BenBran
29-Sep-2009
[9194x2]
Thanks Steeve.  That did the trick.
question:  Why did I not have to 'make the edge initally?
Steeve
29-Sep-2009
[9196x2]
ahah, i was waiting for that question
because the lo block you constructed contains a dialect, not rebol 
code.

When you call the layout function, the dialect is processed and the 
values [edge [...]] are translated to code [face/edge: make face/edge 
[...]]
BenBran
29-Sep-2009
[9198]
Thanks.  I'll let the brain gears process this for a while.
Steeve
29-Sep-2009
[9199]
you can see the source of the layout function to have an idea of 
how the dialect is processed.

But layout is an obfuscated function with too much dependencies with 
other hidden functions.

It's rather difficult to have a whole understanding of how it works.
It reclaims several years of training.
BenBran
29-Sep-2009
[9200]
Then is something like this possible? or does the layout function 
always take input either at that location or the 'edge word as dialect? 
 I guess the question could be... how do we know if we are creating 
code or dialect and does it matter?


view layout [text 100x100 "Hello" edge: make/edge [size: 25x25 color: 
0.0.255 effect: 'bevel]]
Steeve
29-Sep-2009
[9201]
To see if you can, just try it (in your case it fails).
Henrik
29-Sep-2009
[9202]
it won't work, because the edge is not a dialect keyword outside 
of 'with.
BenBran
29-Sep-2009
[9203x2]
Sorry.... should have put the ';; <---- fails' comment next to the 
line.   Hence the rambling questions....
Henrik, that makes sense.  I'll look for docs on the 'with word. 
Thanks.
Henrik
29-Sep-2009
[9205]
Ben, see private message.
james_nak
29-Sep-2009
[9206]
Thanks. That opens my eyes to what I refer to as Rebol Voodoo. One 
can easily forget the relationship between a dialect and Rebol. Good 
stuff.
Steeve
29-Sep-2009
[9207]
It's the central point with Rebol, when a function is accepting a 
block as input, you can't  guess if it will be processed as pure 
rebol code, list of data, or as a dialect (mixed data and commands).
Data is code, Code is data. Never forget.
james_nak
29-Sep-2009
[9208]
Are you kidding? It took me a long time before I stopped turning 
everything into a string with my own functions! :-)
Steeve
29-Sep-2009
[9209x2]
i meant you can't guess until you read the documentation of a specific 
function.
'help and 'source are they magic keys.
*the magical key
james_nak
29-Sep-2009
[9211]
Oh, I like the feeling when I can say "Oh, that's how it works." 
And then there's anamonitor. I can't tell you how many times I've 
gone back and forth with that tool. :-)
BenBran
29-Sep-2009
[9212]
source.... I keep forgetting about that command.  thanks for the 
reminder.
amacleod
4-Oct-2009
[9213]
Having trouble changing the data in a drop-down list...

mylist/list-data: new_stuff 
show mylist

works the first time but not there after
Maxim
4-Oct-2009
[9214]
you must clear /append in the same original block  :-)
amacleod
4-Oct-2009
[9215]
Sorry, not sure what you mean