Gravity Question

manios

Active Member
Licensed User
Longtime User
Hi,

is it possible to set 2 or more Gravity items?

Example: I want 2 Garvity settings on a label!

label1.Gravity = Gravity.RIGHT
label1.Gravity = Gravity.CENTER_VERTICAL

It seems only the last Gravity setting is used.
 
As they show as Ints (I assume they are bits really), you can add them to combine:
Code: Copy
label1.Gravity = Gravity.RIGHT + Gravity.CENTER_VERTICAL
 
Upvote 0
What am i doing wrong?

Hi,
I have a Variable g, which contains two combined Gravity Constants and want to find out, if the bits for gravity.CENTER_HORIZONTAL are set.

The Value of the Variable g was assigned with:
Code: Copy
g = Bit.OR(gravity.TOP, gravity.CENTER_HORIZONTAL)

My idea was to test the Variable g for CENTER_HORIZONTAL with the following code:

Code: Copy
If Bit.AND(g, gravity.CENTER_HORIZONTAL) = gravity.CENTER_HORIZONTAL then
   ...(do something)
End If

this seems to be a bad idea, my code doesn't work:


Code: Copy
Log (Gravity.CENTER_HORIZONTAL)                ->   1
Log (Gravity.LEFT)                             ->   3
Log (Gravity.RIGHT)                            ->   5
Log (Gravity.TOP)                              ->  48
            
g=Bit.Or(Gravity.TOP,Gravity.CENTER_HORIZONTAL)->  49                        

Log (g)                                        ->  49                                
Log (Bit.AND(g,Gravity.TOP))                   ->  48
Log (Bit.AND(g,Gravity.CENTER_HORIZONTAL))     ->   1
Log (Bit.AND(g,Gravity.LEFT))                  ->   1   
Log (Bit.AND(g,Gravity.RIGHT))                 ->   1

With Bit.And i get the same result (1) for LEFT, RIGHT And CENTER_HORIZONTAL

What am i doing wrong? How can i check variables for gravity.CENTER_HORIZONTAL?

Regards,


Joerg
 
Upvote 0
Thank you for your quick reply.

Dealing with the first four bits is too much mathematics for a Basic-Programmer :-)
As a Workaround i will test for LEFT and RIGHT instead.

Regards,
Joerg
 
Upvote 0

Similar Threads

Back
Top