World: r3wp
[View] discuss view related issues
older newer | first last |
Dockimbel 23-Sep-2009 [9137x2] | Here's a quick link to what you're looking for : http://www.hmkdesign.dk/rebol/list-view/docs/list-view.html#section-3 |
Btw, here's another useful link about VID styles : http://www.codeconscious.com/rebol/vid-notes.html | |
BenBran 23-Sep-2009 [9139] | thanks for the links. I do have that list-view, I was trying to find a smaller way out. It was missing one or two features I was wanting last I checked, and didn't feel like pouring over the source code. about 100 pages. My brain would take quite a few months to understand it. Excellent software though. I'll give it some more thought, and thanks again for the vid-notes link. It looks very clean. |
Dockimbel 23-Sep-2009 [9140x2] | Digging out the old but still very good for quick VID learning vid-usage.r script: http://www.rebol.org/view-script.r?script=vid-usage.r |
If you want a small solution, you can use the LIST style, but it's a bit more complex to work with. You can find some examples in the vid-usage.r script (look of some examples is horrible, but it will show you how to build custom multi-column lists). | |
BenBran 23-Sep-2009 [9142] | well.... looking back through my coded examples... I actually have a good working list-box with over l000 rows with the columns correctly spaced. However, its missing some necessary features, one of which is how do i attach the vertical scrollbar to the list box. I tried the vid-usage.r script but perhaps I must have missed some key elements. I'll try looking at that again. |
Dockimbel 23-Sep-2009 [9143x4] | I wrote a quick example to show you how to achieve that : ] |
data: make block! 16 loop 16 [repend/only data [random "012345789" random "abcdefghij"]] visible: 5 ; number of visible lines window: (length? data) - visible ; sliding window size cursor: 0 view layout [ across space 0x0 grid: list 200x100 [ across txt 100 txt 100 ] supply [ if row: pick data count + cursor [face/text: pick row index] ] sc: scroller 16x100 [ cursor: sc/data * window show grid ] do [ sc/step: 1 / window ; initializing scroller steps granularity ] ] | |
Forgot to set the scroller bar size, the 'do init code should be : do [ sc/step: 1 / window ; initializing scroller steps granularity sc/redrag 5 / length? data ; initializing scroller bar size ] | |
or even better : sc/redrag visible / length? data | |
BenBran 24-Sep-2009 [9147] | That is an excellent example. Answered many questions I had (and raised a few more). Thank you for taking the time to show me this Dockimbel. |
Dockimbel 24-Sep-2009 [9148x2] | I'm glad it helped you. It was a good opportunity for me to refresh my memory about the (powerful but under-documented) LIST style. |
In case you're wondering about the block after SUPPLY, it's used internally by the LIST style to build an iterating function defining a local context where COUNT refers to the current row and INDEX to the current column. Each horizontally positionned face (purpose of the ACROSS keyword) defined in the LIST layout block, is counted as a column, so: txt 100 txt 100 => 2 columns. | |
amacleod 24-Sep-2009 [9150] | I'm need to get the name I assigned a face when I alt-click on it. I can get its style, offset, size etc but I do not see a way to get the face's name. More specificly I have multiple scroll-panels and I need to know the one I'm clicking in... |
Graham 24-Sep-2009 [9151] | What name? |
amacleod 24-Sep-2009 [9152x3] | a: scroll-panel [blah blah blah b: scroll-panel [blah blah blah I want to know if I clciked in scroll-panel a or b |
if event/type = 'alt-down [face/style] ...gives me 'scroll-panel' how do i get 'a' or 'b' | |
Sorry for the possible confusion but its one of anton's styles but did not think it would make a diff. | |
Graham 24-Sep-2009 [9155] | face = a ?? |
Henrik 24-Sep-2009 [9156] | face/var |
amacleod 24-Sep-2009 [9157x2] | yeah? |
it works... | |
Henrik 24-Sep-2009 [9159] | of course it does :-) |
amacleod 24-Sep-2009 [9160x2] | I thought about var but I thhought that would be too simple to work... Thanks alot Henrik! |
Is that because its Anton's style or is that a rebol thing for all faces? | |
Henrik 24-Sep-2009 [9162x2] | no problem |
face/var is set during layout for all faces that have a set-word! attached. | |
amacleod 24-Sep-2009 [9164] | great! Thanks! |
Henrik 24-Sep-2009 [9165x4] | you can also set it yourself like this: scroll-panel [with: 'a] |
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 [9186] | 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. |
older newer | first last |