B4J Question Node visibility outside container

mediait

Member
Licensed User
Longtime User
If I have a pane containing a label then move that label outside the pane dimensions the label is still visible.

What I am trying to do is slide nodes from outside a pane into the pane display, but only be visible when it is within the pane dimensions.

Can anyone help?
 

mediait

Member
Licensed User
Longtime User
From what I can understand you can use setClip() method of pane to hide anything outside of a rectangle dimensions.

B4X:
Rectangle clipRect =newRectangle(pane.getWidth(), pane.getHeight());
pane.setClip(clipRect);

I have tried the following:
B4X:
Dim rectangle As JavaObject
rectangle.InitializeNewInstance("java.awt.Rectangle", Array As Object(myPane.width, myPane.height))

Dim obj As JavaObject = myPane
obj.RunMethod("setClip",Array(rectangle))

but I get:
java.lang.RuntimeException: Method: setClip not matched
which I gather means I am not supplying the correct arguments for setClip().

Any ideas anyone?
 
Upvote 0

mediait

Member
Licensed User
Longtime User
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.SetFormStyle("UNIFIED")
    'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
    MainForm.Show
  
    Dim p As Pane
    Dim l As Label
  
    p.Initialize(Null)
    l.Initialize(Null)
  
    MainForm.RootPane.AddNode(p,0,0,200,200)
    p.Style = "-fx-background-color: #888888;"
    p.AddNode(l,100,0,200,50)
    l.Text = "Hello world and world and world"
End Sub

Below shows the label text outside the pane.

b4j.jpg
 
Upvote 0

mediait

Member
Licensed User
Longtime User
I appreciate your time Erel, but there are unknown number of panes added dynamically in 20 second slides containing either labels or images and these nodes are animated within their containers.

Is there a way of clipping the panes at runtime?
 
Upvote 0

mediait

Member
Licensed User
Longtime User
B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private stubPane As Pane
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.SetFormStyle("UNIFIED")
    MainForm.RootPane.LoadLayout("layPane") 'Load the layout file.
    MainForm.Show
   
    Dim l As Label
   
    l.Initialize(Null)
   
    stubPane.Style = "-fx-background-color: #888888;"
    stubPane.AddNode(l,100,0,200,50)
    l.Text = "Hello world and world and world"
   
End Sub

It is still the same. Text is still displayed outside the container.

Is there no way of clipping the panes at runtime?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Is there no way of clipping the panes at runtime?
It is not so simple.

This is how it looks here:

SS-2016-06-19_13.13.15.png


Note that it is a mistake to set the style like this. It is better to set it in the designer or with CSSUtils. You should also pass an empty string as the event name (both are not related to the clipping issue).
 
Upvote 0

mediait

Member
Licensed User
Longtime User
Thanks for your time Erel. I was using the Scene Builder to create the layout but I saw from your example I should have been using the Open Internal Designer.
I have changed my programme code to load predefined panes from a layout and the pane nodes are now contained. :)
 
Upvote 0
Top