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
[8681x2]
basically, if you return none, the event is consumed and not sent 
to view's default wake-event

if you return the event itself, the next input handler in the chain 
will be fired.
(next event handler being view's default wake-event)
Henrik
12-May-2009
[8683]
hmm.. basically what I have for detect is sitting now in the window-feel. 
So I could move it out into a separate function and use INSERT-EVENT-FUNC 
on it?
Maxim
12-May-2009
[8684x2]
give me a minute, I'll make you an explicit example in rebol code, 
from some source I have here  :-)
it actually takes less text to code it than to explain it.   ;-)
Henrik
12-May-2009
[8686]
ok, I'll go make a cup of chocolate :-)
Maxim
12-May-2009
[8687x3]
rebol []

ctx: context [
	coord: none
	handler: insert-event-func [
		; disable half of the window's events
		if event/offset/x > (event/face/size/x / 2) [
			probe event/offset
			event
		]
	]
]


window: view layout [button "ok"]
note: 

-if returns none when it doesn't match, so that is returned from 
the handler.

-I put the handler within a ctx, just to allow for local vars within 
handler (which I don't use, but figured I'd demonstrate, for all 
to see)
I remind myself, how complicated those few lines would be to implement 
in .net and I continue to say that rebol is still conceptually, if 
not in capacity, better than most solutions out there.
Henrik
12-May-2009
[8690x2]
I'm not sure it explains much, as you keep talking about consuming 
events. From what I gather from system/view/screen-face/feel, the 
event functions are just stacked in there and invoked using 'detect, 
which to me appears to be the same as the window-feel.
I.e. they would still be invoked in the reverse order of what I need.
Maxim
12-May-2009
[8692]
when you run the above, half of the windows events are consumed by 
the new event handler, since we return none on the left side of the 
window.
Henrik
12-May-2009
[8693]
yes, I can see that.
Maxim
12-May-2009
[8694x2]
you could instead trigger a function here, (if proper conditions 
are met) and return event all the time.
so your windows/feel/on-something would happen before it does its 
normal event handling
Henrik
12-May-2009
[8696]
That's exactly the opposite of what I want. It already does that. 
:-)
Maxim
12-May-2009
[8697]
but here, if the trigger is met, you can call the do event yourself 
and THEN call your function   :-)  by returning none, the normal 
view handler will then ignore the event (since you've already handled 
it)
Henrik
12-May-2009
[8698]
I really think I need this painted on a big card board sign, because 
I don't get it. Would the original detect first need to be blocked, 
then the engage would run and then we run the detect again?
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 ?