|
- Forum - iziBasic
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 257
Sujet n° 1345 |
Scrollbar difficulties? |
le 17/01/2006 @ 00:44 par Nevin Morrison
|
I am fairly new to izibasic. I want to a add a scroll bar to a program. I have added it, but it does nothing. How do I get the screen to scroll when the car is moved. Could someone please send me a sample code of how this works. Is it some type of on event code? Will it scroll all objects or just text? |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 1 -------- le 17/01/2006 @ 10:11 par aldweb
visiteur |
Hello Nevin,
It is up to you to detect when a scrollbar event occured (with the DOEVENTS or WAITEVENT function returning the scrollbar #), then detect the car position (with the SCROLLBAR() function) and have your source code do whatever you wished the scrollbar to do.
Quick example:
SCROLLBAR #1,1,150,50,9,100 REPEAT E=DOEVENTS IF E=1 GOSUB _MyScrollBar 'Car moved UNTIL E=-1 : END
_MyScrollBar: C=SCROLLBAR(#1) 'Car position in [1..100] 'do whatever you wish following scrollbar's change RETURN
Why not offer an automatic behavior for scrollbars, especially with fields? Because I believe that the way offered in iziBasic is much more flexible by not only attaching scrollbars to fields, and leaving them as independant objects which can interact, by code, with the form and the other objects in the form.
Cheers, aldweb
|
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 2 -------- le 17/01/2006 @ 15:50 par Nevin
visiteur |
I thought that I would probably need to do that. I was just looking for an easy way before I did it that way. I just wanted to check. Thanks, Nevin |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 3 -------- le 18/01/2006 @ 15:51 par Nevin Morrison
visiteur |
I still am having problems with the scrollbar. I think that I do not understand how to access the scrollbar function properly. Can you take a look at this code and tell me what is wrong with it:
BEGIN LABEL #3,"Nothing",15,35 SCROLLBAR #1,1,150,50,9,100 REPEAT E=DOEVENTS IF E=1 GOSUB _SCROLLBAR UNTIL E=-1 :END END
_SCROLLBAR: C=SCROLLBAR(#1) B=2 IF C>=B THEN GOSUB _MoveDown ELSE GOSUB _MoveUp END IF RETURN
_MoveDown: T=T-5 UPDATEPOS #3,30,T RETURN
_MoveUp: T=T+5 UPDATEPOS #3,30,T RETURN
|
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 4 -------- le 19/01/2006 @ 17:29 par aldweb
visiteur |
Hello Nevin,
The issue seems to be in your _SCROLLBAR: routine. C=SCROLLBAR(#1) returns a car value between 1=top and 100=bottom. So 50=middle of scrollbar.
IF C>=B THEN returns true whenever C>=2 so at the very top of the scrollbar. Then, unless you really tick the top of the scrollbar, your LABEL #3 will always switch to _MoveDown: (but, in reality, it will move "up" the screen by 5 pixels!).
Anyway, this relative moving is not the right one. You should fix your top and bottom virtual scrolling window. Then, according to the relative scrollbar car position (and this is where the [1..100] range is smart as it can be used as a percentage), detect what is the frame to show of this window and align the LABEL accordingly.
Cheers, aldweb
|
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 5 -------- le 19/01/2006 @ 19:02 par Nevin
visiteur |
I do not understand how to fix my top and bottom virtual scrolling window. But I may have to do some more reading of your manual. I am sorry to bother you with this many questions. I do not really have a need for the scrollbar in the current app. I have been working on I just wanted to learn how to do it. Anyways I will try to figure it out. I have developed a work around where I can move objects in all 4 dirrections with push buttons if needed, but I would like to do it the right way. Is there anywhere to post code or apps that have been developed on your site so that I can share my material. I have an application that demonstrates the use of a timer that may be useful to other developers(or maybe they have a better way).
Thank you for your help,
Nevin
Letbridge, Alberta, Canada |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 6 -------- le 21/01/2006 @ 15:50 par aldweb
visiteur |
Nevin,
Try this code:
BEGIN LABEL #3,"Nothing",15,40 SCROLLBAR #1,1,150,50,9,110 REPEAT E=DOEVENTS IF E=1 THEN C=SCROLLBAR(#1)+40 UPDATEPOS #3,15,C END IF UNTIL E=-1 END Cheers
@+ aldweb |
|
|
sujet actif
sujet clos
Important!
Nouveau message -
Rectifier message
Clôturer sujet
Remonter
|
|