Thanks Erel I had already tried but it doesn't work.Add: MainForm.RootPane.PickOnBounds = True
Yes, yesNo. It should be MainForm_MouseMoved (non-B4XPages project).
Troppo semplice LucaMs, il pannello non deve essere solido altrimenti non ci sono problemiAdd a Pane to that area.
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.SetFormStyle("TRANSPARENT")
MainForm.RootPane.LoadLayout("Layout1")
MainForm.BackColor = fx.Colors.Transparent
pnTransparent.Style = "-fx-background-color:transparent;"
MainForm.Show
End Sub
It is set as transparent in the Designer.pnTransparent.Style = "-fx-background-color:transparent;"
???I need that transparent area because inside I show an external program.
you must also put Main transparent but from codeIt is set as transparent in the Designer.
It is right what you say but with transparency not at the maximum I can no longer interact with what is in the transparent areaSearched the issue and found out that it seems this is a Windows problem, not related to JavaFx. An ugly solution is to put a pane on that transparent area and set its alpha to 0.1. It's not totally transparent but better than nothing. I tried and it works and 0.1 alpha is almost transparent - hardly to distinguish.
Perfect stevel05Out of curiosity, I thought I'd try a solution using Roycefers jNativeHook library. There are obvious potential issues using this kind of library, mainly it is important to make sure that you stop the native hook when the app is closed. Due to it's nature, it is not simple to work with, but it can be very effective and I have an app that relies on it which I use daily and have done for the last 3 or 4 years with no issues.
Please read carefully Roycefer's comments in the library post.
I have tested this on java 8 and 11, and have added the code to capture mouse press which you may want and requires the Threading library and therefore may not run properly in debug mode unless you compile it to a library. If you don't need it I suggest that you remove it.
It's not going to be perfect as it stands but should give you a start. I hope this helps.
#If JAVA
import java.awt.MouseInfo;
public static double ScreenMousePos() {
return MouseInfo.getPointerInfo().getLocation().getX();
}
#End If
'Process Globals
Private AMP As AwtMousePointer
.
.
'Appstart
AMP.Initialize(Me, MainForm)
.
.
Private Sub AWTMousePointer_MouseMoved(X As Int, Y As Int)
Log(X & ", " & Y)
End Sub
#Event: MouseMoved(X as Int, Y as Int)
Sub Class_Globals
Private fx As JFX
Private MPTimer As Timer
Private MouseInfo As JavaObject
Private MouseMoved As Boolean
Private mCallBack As Object
Type MousepointerType(X As Int, Y As Int)
Private MPT As MousepointerType
Private TargetForm As Form
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(Callback As Object, F As Form)
mCallBack = Callback
TargetForm = F
MPTimer.Initialize("MPTimer",100)
MouseInfo.InitializeStatic("java.awt.MouseInfo")
MouseMoved = SubExists(mCallBack,"AWTMousePointer_MouseMoved")
MPT.Initialize
MPTimer.Enabled = True
End Sub
Private Sub MPTimer_Tick
Dim Location As JavaObject = MouseInfo.RunMethodJO("getPointerInfo",Null).RunMethodJO("getLocation",Null)
Dim NewMPT As MousepointerType
NewMPT.Initialize
NewMPT.X = Location.RunMethod("getX",Null)
NewMPT.Y = Location.RunMethod("getY",Null)
If NewMPT.X = MPT.X And NewMPT.Y = MPT.Y Then Return
MPT = NewMPT
If MouseMoved And OverWindow(MPT) Then
CallSub3(mCallBack,"AWTMousePointer_MouseMoved",(MPT.x - TargetForm.WindowLeft).As(Int), (MPT.Y - TargetForm.WindowTop).As(Int))
End If
End Sub
Private Sub OverWindow(TMPT As MousepointerType) As Boolean
If TMPT.X >= TargetForm.WindowLeft And _
TMPT.X <= TargetForm.WindowLeft + TargetForm.WindowWidth And _
TMPT.Y >= TargetForm.WindowTop And _
TMPT.Y <= TargetForm.WindowTop + TargetForm.WindowHeight Then
Return True
Else
Return False
End If
End Sub