B4J Question Trying to position a button by code, its not moving?

aidymp

Well-Known Member
Licensed User
Longtime User
I wrote a big sub to do this but nothing happened.

so I just tried this line

B4X:
Button2.Left=250

but still the button fails to move? am I missing something?

Thanks

Aidy
 

aidymp

Well-Known Member
Licensed User
Longtime User
Here is a blank project, opened designer, added a button, tried some basic code

B4X:
Button1.Left=130
Button1.PrefHeight=66

nothing happens to the button?

project attached

Seems like its ignoring me! lol
 

Attachments

  • movebutton.zip
    1.6 KB · Views: 276
Upvote 0

aidymp

Well-Known Member
Licensed User
Longtime User
Uhm...

If you move the code (those 2 lines) to Sub Button1_Action, for example, it works.

B4j does not have commands like DoEvents, Invalidate, Refresh... I'm searching for a solution, but If someone (Erel? )...

Very strange, I have a sub called Scheme, i put the code in there like

B4X:
#Region  Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 400
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private Button1 As Button
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.SetFormStyle("UNIFIED")
    MainForm.RootPane.LoadLayout("form") 'Load the layout file.
    MainForm.Show
    scheme
End Sub

Sub scheme
    Button1.Left=130
    Button1.PrefHeight=66
End Sub

Still nothing happens, lol
 
Upvote 0

aidymp

Well-Known Member
Licensed User
Longtime User
So simply removing the tick, fixes the problem! Thanks to both of you. I was beginning to think SHOUTING AT IT MAY HELP! lol

Thanks Guys as always awesome!
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User


Ehm... I tried (before your post, then I'm not so stupid, lol) searching for some form/pane event (thank to the very useful "help of tab"), but I don't know the panel name, so I don't know the full event name.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…