B4J Question Scroll mouse event ?

hookshy

Well-Known Member
Licensed User
Longtime User
I did not found any scroll mouse event ?

I post recently a simple example on how to move a pane , using the midle scroll button it defines the pan action over a pane .
How will I do the zoom ?

I did thought I could do zoom as in layout designer but it would have been nice to use mouse as in all other graphics software !
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can add an OnScroll event to a node with JavaObject:
B4X:
Sub Process_Globals
   Private fx As JFX
   Private MainForm As Form
End Sub

Sub AppStart (Form1 As Form, Args() As String)
   MainForm = Form1
   MainForm.Show
   Dim jo As JavaObject = MainForm.RootPane
   Dim e As Object = jo.CreateEventFromUI("javafx.event.EventHandler", "scroll", Null)
   jo.RunMethod("setOnScroll", Array(e))
End Sub

Sub Scroll_Event (MethodName As String, Args() As Object) As Object
   Dim scrollevent As JavaObject = args(0)
   Log(scrollevent.RunMethod("getDeltaY", Null))
   Return Null
End Sub
 
Upvote 0

hookshy

Well-Known Member
Licensed User
Longtime User
thanks Erel I will try it ...

Regarding the zoom over pane that contain different objects ...I did manage scale image and parent dimensions in order to get the zoom
but yet i try to imagine a way to zoom over text ... for now I leave the text in original font size

Q: How could I scale the text size according to reference objects ? knowing that I have to restore original text size on 100% zoom
any hints ?
 
Upvote 0

hookshy

Well-Known Member
Licensed User
Longtime User
I am trying to figure out how to maintain the aspect ration of objects while zooming ... like abstract designer zoom to 50%

I do find difficult to put the question !
Do I have to make a grid snap in order to make the proper scaling ?
How do I increment the imageviews sizes relative to panel size ... actually I do not know how to scale the parent to mantain aspect ratio and distances between objects
Quite a hard task ..

Any hints will be apreciated


I must ajust left,top dimensions relative to zoom level ..easy said than done
 
Last edited:
Upvote 0

hookshy

Well-Known Member
Licensed User
Longtime User
I did think about it ...I can resize all objects with zoom factor as well as the parent window ...then
I must reposition all object on the new modified parent to fit the old left,top dimensions ..in this way I will maintain the real distance between objects
if an image view was on 20dip left and 20dip top then ... on a zoom level of 200% the new position must be 40dip left 40dip top ...

I did have some problems because I used a scale factor like
imgx.width=imgx.wdth*1.1
imgx.width=imgx.wdth/1.1
this was in my opinion a mistake then I made a scale adding dimensions like:
imgx.width=imgx.wdth+10
imgx.width=imgx.wdth-10
parent.width=parent.width+10
parent.height=parent.height +10

I do not now if I will make it work till the end but I like thing about how stuff works ... I guess all other features of my project will be great also ..
I am building a hmi for industrial wwtp that will connect to various plc
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…