Re: shifting controls - the solution, sort of (REALbasic getting started Mailinglist archive)
Back to the thread list
Previous thread: Saving data to an external file
Next thread: programming algorithms 101 - was shifting controls up and down
| Re: shifting controls - the solution, sort of - Russ Jones | |
| Re: shifting controls - the solution, sort of - Terry Ford | |
| shifting controls - the solution, sort of - Koen van Hees | |
| Re: shifting controls - the solution, sort of |
| Date: 29.07.06 13:01 (Sat, 29 Jul 2006 08:01:33 -0400) |
| From: Russ Jones |
|
On Jul 29, 2006, at 5:23 AM, Koen van Hees wrote: > I found a solution. I think. > It works very well, First, congratulations on arriving at a working solution. > but I feel I'll have to revisit this > when I get better at this programming thing. I haven't looked at your problem or your solution in detail, but from a glance at your solution, it seems to me that this would be a good application for control arrays. You may also find making your own subclasses of some controls quite useful. Please keep learning. There is a lot to learn, and it can be rewarding. Russ _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html> |
| Re: shifting controls - the solution, sort of |
| Date: 29.07.06 15:39 (Sat, 29 Jul 2006 07:39:28 -0700) |
| From: Terry Ford |
|
On Jul 29, 2006, at 2:23 AM, Koen van Hees wrote: > Not getting replies on my question made me doubt my question, > so I found a solution. I think. > It works very well, but I feel I'll have to revisit this > when I get better at this programming thing. First of all, please *do not cross-post* to both lists. You might find yourself booted off of the lists as REAL really frowns upon it. Also many won't answer now as they agree. Since you are obviously learning the basics, the Getting Started list is best to stick with. Another thing you should be aware of is that Container controls are a *pro-only* feature and relatively new at that. This limits the list a bit more. > I took the disclosuretriangles out of the containers, thus solving > the stupid problem I had created. Now I can trigger the right > behavior using the triangle's action handler. Correct. > And this code I put in every triangle, but with only the code > applying to itself and those controls below it. > > The obvious disadvantages are: > - I have to know the amount of controls beforehand Not necessarily. You can keep track of how many groups you have in a variable and use a sub-classed disclosure triangle control array to keep a single copy of any similar code in methods of the sub-class. > - this is a lot of code and there's no method I can refer to in > every triangle instead of putting something very similar in every > triangle handler Each Disclosure Triangle has an index which you can use to identify which one is clicked on. > If you have any comments, please feel free! Thanks. Do simple tests to learn how to use control arrays and sub-classes before trying the all at once final approach. The control array is the most important as the methods can be in the window as well in many cases. Search the archives (in the footer) for control arrays and you will find lots of information. Look in both GS and NUG as one is older than the other (NUG). Terry PS. Try to stick to one thread rather than a new subject each time. _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html> |
| shifting controls - the solution, sort of |
| Date: 30.07.06 11:25 (Sun, 30 Jul 2006 12:25:52 +0200) |
| From: Koen van Hees |
|
I am not going to make a habit of feeding my
own threads, but I've posted a "solution" of a problem, and after a little thinking I came to the conclusion that 1) my solution was no good 2) there was a much simpler way to do it. So here's hopefully the last mail on this subject. After this, I imagine I'll be posting a lot less. I have a bunch of controls that can be shown or hidden by clicking a disclosure triangle. They are positioned below each other like this |> control1 |> control2 ... I've written a method that does a couple of things to accomodate for this changing of sizes. This method is triggered through a disclosure triangle's action handler. Here's the method. // declare all the controls Dim DT1, DT2, DT3, DT4, DT5, DT6, DT7, DT8, DT9 As DisclosureTriangle DT1=DisclosureTriangleAD1 DT2=DisclosureTriangleAD2 DT3=DisclosureTriangleAD3 DT4=DisclosureTriangleAD4 DT5=DisclosureTriangleAD5 DT6=DisclosureTriangleAD6 DT7=DisclosureTriangleAD7 DT8=DisclosureTriangleAD8 DT9=DisclosureTriangleAD9 Dim st2, st3, st4, st5, st6, st7, st8, st9 as StaticText st2=StaticTextAD2 st3=StaticTextAD3 st4=StaticTextAD4 st5=StaticTextAD5 st6=StaticTextAD6 st7=StaticTextAD7 st8=StaticTextAD8 st9=StaticTextAD9 dim cc1,cc2,cc3,cc4,cc5,cc6,cc7,cc8,cc9 As ContainerControl cc1=ContainerControlArtDetail1 cc2=ContainerControlArtDetail2 cc3=ContainerControlArtDetail3 cc4=ContainerControlArtDetail4 cc5=ContainerControlArtDetail5 cc6=ContainerControlArtDetail6 cc7=ContainerControlArtDetail7 cc8=ContainerControlArtDetail8 cc9=ContainerControlArtDetail9 dim ca As Canvas ca=CanvasArt ca.Height=330 //set the initial position of the controls //extremely important! DT2.top=DT1.top+30 DT3.top=DT2.top+30 DT4.top=DT3.top+30 DT5.top=DT4.top+30 DT6.top=DT5.top+30 DT7.top=DT6.top+30 DT8.top=DT7.top+30 DT9.top=DT8.top+30 // check for every disclosure triangle if it's //open or not and depending on its state: //show the hidden controls, shift the under- lying triangle and make the canvas bigger if DT1.Value=false then cc1.Visible=False DT2.top=DT1.top+30 else cc1.Visible=True DT2.Top=DT1.Top+300 ca.Height=ca.Height+300 end if if DT2.Value=false then cc2.Visible=False DT3.top=DT2.top+30 else cc2.Visible=True DT3.Top=DT2.Top+300 ca.Height=ca.Height+300 end if if DT3.Value=false then cc3.Visible=False DT4.top=DT3.top+30 else cc3.Visible=True DT4.Top=DT3.Top+300 ca.Height=ca.Height+300 end if if DT4.Value=false then cc4.Visible=False DT5.top=DT4.top+30 else cc4.Visible=True DT5.Top=DT4.Top+300 ca.Height=ca.Height+300 end if if DT5.Value=false then cc5.Visible=False DT6.top=DT5.top+30 else cc5.Visible=True DT6.Top=DT5.Top+300 ca.Height=ca.Height+300 end if if DT6.Value=false then cc6.Visible=False DT7.top=DT6.top+30 else cc6.Visible=True DT7.Top=DT6.Top+300 ca.Height=ca.Height+300 end if if DT7.Value=false then cc7.Visible=False DT8.top=DT7.top+30 else cc7.Visible=True DT8.Top=DT7.Top+300 ca.Height=ca.Height+300 end if if DT8.Value=false then cc8.Visible=False DT9.top=DT8.top+30 else cc8.Visible=True DT9.Top=DT8.Top+300 ca.Height=ca.Height+300 end if if DT9.Value=false then cc9.Visible=False else cc9.Visible=True ca.Height=ca.Height+300 end if //now that all the triangles are at the right //position, make sure that other controls //are as well, and btw, //this would be more elegant using indexes st2.Top=DT2.top st3.Top=DT3.top st4.Top=DT4.top st5.Top=DT5.top st6.Top=DT6.top st7.Top=DT7.top st8.Top=DT8.top st9.Top=DT9.top cc2.Top=st2.Top+32 cc3.Top=st3.Top+32 cc4.Top=st4.Top+32 cc5.Top=st5.Top+32 cc6.Top=st6.Top+32 cc7.Top=st7.Top+32 cc8.Top=st8.Top+32 cc9.Top=st9.Top+32 Well, there you have it. I hope will be useful to somebody, because as trivial as it looks, it took me a lot of boiled brain cells to get here. Koen van Hees Les Allées de St. Genis 299 Allée Diderot 01630 St Genis Pouilly France tel: +33 (0)4 50 42 08 78 _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html> |
Links
MBS REALbasic Plugins - Pfarrgemeinde Ministranten Nickenich