Android Question B4XPage Touch not working

Darsiar

Member
B4XPage does not call the screen touch response routine:

B4X:
#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region

'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip

Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    
    Public cvs  As B4XCanvas 
    
    Public dg As Diagram
    
End Sub

Public Sub Initialize
    dg.Initialize
    
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    
    'Root.LoadLayout("MainPage")
    cvs.Initialize(Root)

    '  создать ноды для Фрейма № 1
    dg.AddNode(1,"n1","Node-1","Base",300,200)
    dg.AddNode(1,"n2","Node-2","Base",150,300)
    dg.AddNode(1,"n3","Node-3","Base",400,350)
    
    ' соеденить ноды
    dg.AddRelase("n1","n2","Base")
    dg.AddRelase("n1","n3","Base")
    
    ' нарисовать фрейм
     RddrawAll(1)
End Sub

'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.


' перересовка всего кадра
 Sub RddrawAll(frame As Int)
    'Dim bc As BitmapCreator ',  pnl  As B4XView
    
    'bc.Initialize(Root.Width / xui.Scale, Root.Height / xui.Scale)
    
    
    For Each i As DiagramNode In dg.Nodes.Values
        If i.Frame = frame Then
            i.ReDraw(xui, Root,cvs)
        End If
    Next
    'Root.SetBitmap(bc.Bitmap)
End Sub

Private Sub Root_Touch (Action As Int, X As Float, Y As Float)
    Select Action
        Case Root.TOUCH_ACTION_MOVE_NOTOUCH
        Case Root.TOUCH_ACTION_DOWN
            dg.TouchSelect(1,X,Y)
        Case Root.TOUCH_ACTION_MOVE
            If dg.MoveSelectedNode(X,Y) Then
                 RddrawAll(1 )
            End If
        Case Root.TOUCH_ACTION_Up
            dg.SelectNode =Null
    End Select
End Sub
 

Darsiar

Member
ERROR!
Error occurred on line: 22 (B4XMainPage)
java.lang.RuntimeException: Object should first be initialized (B4XView).

B4X:
Sub Class_Globals
    Private Root As B4XView
    Private activePanel As B4XView
    Private xui As XUI
   
    Public cvs  As B4XCanvas
   
    Public dg As Diagram
   
End Sub

Public Sub Initialize
   
   
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
   
    'Root.LoadLayout("MainPage")
    cvs.Initialize(activePanel)
 
Upvote 0

Darsiar

Member
I added a panel, and I'm trying to connect it, but all options give errors:
ERROR!
Error occurred on line: 8 (B4XMainPage)
java.lang.RuntimeException: Object should first be initialized (Panel).

B4X:
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
 
    '  Dim activePanel As B4XView
    'Panel1.Initialize("Panel1")  
    'activePanel.AddView(Panel1,0,0,Panel1.Width,Panel1.Height)
    cvs.Initialize(Panel1)
 
Upvote 0

Darsiar

Member
Resolved!
Through complex manipulations with a tambourine, we figured out how to do it right.
Dear Erel, we need more detailed instructions about each innovation. Everything is fine with the new pages, but not as obvious as with the old activation tutorial.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…