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

World: r3wp

[View] discuss view related issues

Maxim
12-May-2009
[8699x5]
working on an exact example  :-D
somehow I can't seem to get the resize events in my window... that 
is strange.
I just realized I had a slightly skewed view of the event ordering, 
but in essence the above still holds.
darn, 8 years of view and I still discover some little tricks and 
details  ;-)
ok for your specific need, the easiest is to hack the wake-event. 
 the insert-event-handler event chain is triggered by of  "do event" 
 handling
Henrik
12-May-2009
[8704]
hacking the wake-event function?
Maxim
12-May-2009
[8705x5]
giving you an example.
rebol []


view*: system/view
; code taken with [probe second get in system/view 'wake-event]
view*/wake-event: func [port ] bind [
    event: pick port 1
    if none? event [

        if debug [print "Event port awoke, but no event was present."]
        return false
    ]
    either pop-face [

        if in pop-face/feel 'pop-detect [event: pop-face/feel/pop-detect 
        pop-face event]
        do event
        found? all [
            pop-face <> pick pop-list length? pop-list
            (pop-face: pick pop-list length? pop-list true)
        ]
    ] [
        do event
        ; OUR HACK >>
        if event/type = 'resize [
        	event/face/feel/after-resize event/face event
        ]
        ; <<
        empty? screen-face/pane
    ]
] in view* 'self

window: view/new/options layout [bt: button "ok" ] [resize]

window/feel: make window/feel [
	after-resize: func [face event ][
		;probe event/type
		;probe "AFTER RESIZE"
		if event/type = 'resize [
			bt/offset/x: face/size/x / 2 - (bt/size/x / 2)
			show bt
		]
		event
	]
]
do-events
note that the actual wake event code comes from the rebol itself, 
you get its code by using:

probe second get in system/view 'wake-event

the change is included between ; OUR HACK >>   <<
does that work for you?
I integrate the scrollwheel within this hack, allowing all faces 
to have an on-scroll  feel.
Henrik
12-May-2009
[8710]
I'll have to test this later. Thanks. Bedtime now.
Maxim
12-May-2009
[8711]
happy to help :-)
Henrik
13-May-2009
[8712x2]
I've looked at the solution for a bit, and I don't think it's flexible 
enough.


I would rather leave the event handling system untouched and then 
in the window-feel specify that we need to do something after the 
engage. Then there would be another event handler, which handles 
events generated by the original 'detect. Is it possible to generate 
events inside the detect, that can be handled by the window-feel 
after the engage?


The problem would otherwise be that the event needs to be handled 
in every single engage function (dozens).
Nevermind, maybe it works after all.
Maxim
13-May-2009
[8714]
there is no way that I know of to do code after the do events processes 
it, a part from adding oprations in the wake event.  and the detect 
is the first part of that process, the inset event handlers are part 
of the detect phase, as I discovered yesterday.
Henrik
13-May-2009
[8715]
now I need something else: making a face completely event transparent.
Maxim
13-May-2009
[8716x2]
event transparent?
like face/feel: none
Henrik
13-May-2009
[8718x3]
I tried that without success.
I will try it again though, just to see if I did something wrong.
Nope, it doesn't work.
Maxim
13-May-2009
[8721x2]
the problem, is that some init blocks of some faces might create 
the feel on the fly, so for best effect, append the face/feel: none 
 to the init block.
the window feel, for example is recreated anytime you unview/show 
window.
Henrik
13-May-2009
[8723]
Well, I've already looked at the feel block for the face after the 
layout is created and shown and it still says none!. If it works 
correctly, it should be possible to click with the mouse through 
that face, shouldn't it?
Maxim
13-May-2009
[8724x2]
yes.
I create dynamic faces all the time, which are basically neutralized 
by face/feel none.
Henrik
13-May-2009
[8726x2]
if the face is the last one in the window pane, that shouldn't have 
any effect on feel being none, should it?
I'm just trying to create a simple floating rectangle.
Maxim
13-May-2009
[8728]
no, you are saying the window event does not receive mouse events, 
for example, if the rectangle is within the window?
Henrik
13-May-2009
[8729]
If I hover it above a text field, I can type text in the field, but 
I can't click on the field to mark up text with the mouse.
Maxim
13-May-2009
[8730]
do you a small example you can post ?
Henrik
13-May-2009
[8731]
view layout [at 0x0 field at 0x0 box with [feel: none]]
Maxim
13-May-2009
[8732x3]
strange... you've got me puzzeled!!
I'm am sensing a few minutes of lost time ahead  ;-)
well, it seems that the do event handling really is not great.  I've 
tried all I know and it really looks like:

 if a face from a diffrent branch is over another face, it blocks 
 all events to underlying faces.  only child faces can pass events 
 to their parents... this is pretty evil.


You could use Anton's do event simulator lib, and hack it so it allows 
this.  :-(   you'd have to remember that a  face has required/handled 
the event (in its detect) and stop looking amongst further pane branches.
Henrik
13-May-2009
[8735x2]
I think I'll do something else, which is pretty clumsy, but I think 
it can work.
Thanks for the help.
Maxim
13-May-2009
[8737]
Its also possible that Anton, Gabriele or Cyphre have found a trick. 
 I'd be interesed to know in any case, cause this could be a problem 
for me in the future too.
Henrik
13-May-2009
[8738]
yes, even this fix is rather expensive. one face for each side instead 
of one, but maybe it will speed up redrawing big faces a bit.
Henrik
14-May-2009
[8739x2]
Maxim, do you know how the iterated faces function is used in View? 
I'm stuck in a situation where the index is sometimes returned as 
none.
never mind, I think I got it.
Anton
14-May-2009
[8741]
You can't do event-transparent faces. I figured out a huge hack (simulating 
DO EVENT) which was not quite able to go the whole way. :-(
Steeve
14-May-2009
[8742]
your transparent face can throw back the events to the underllying 
faces, you just have to locate them with the offset of the events, 
i used this trick several times
Anton
14-May-2009
[8743]
Can I see a demo of your technique, Steeve?

I wanted transparent events along with transparent regions of a face 
(eg. a face with rounded corners, the events should pass through 
the corner regions, but the rest should land on the face).
It just couldn't be done properly - see my file
http://anton.wildit.net.au/rebol/gui/transparent-events.r
Steeve
14-May-2009
[8744]
even in R3 Carl use the same trick
Anton
14-May-2009
[8745x4]
Try click on the button at the left and drag to the right.
I want to see code. (But got to go - I'll check back later.)
(My stuff all relates to R2, by the way.)
(and not at all to R3)