Cancel
Showing results for 
Search instead for 
Did you mean: 

UI.Block buttons clicked unwantedly

Legend
Legend

Hi,

I have a problem with a two dialog vb.net SNAP program in compiled mode using UI.Blocks. (NX 12.0.2)

I have two dialogs: dialog A and dialog B.

I have 4 buttons on dialog A which one of them opens dialog B.

When I go to dialog B and finish my job by clicking OK I come back to dialog A but all other buttons on dialog A are clicked unwantedly!!

I have handled all button clicks by onUpdate function and checking the changed block inside onUpdate.

I don't know what to do about it.

Do you have any Idea?

Regards.

 

13 REPLIES 13

Re: UI.Block buttons clicked unwantedly

Gears Phenom Gears Phenom
Gears Phenom

Can you post the onUpdate() method code of dialog A...

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | KF
Production: [NX8.5.3.3 MP11 64bit] Testing: [NX12.0.2 MP1]

Re: UI.Block buttons clicked unwantedly

Legend
Legend

Hi @Inch

this is the OnUpdate sub in dialog A class:

 

    Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)

        If changedBlock = constraintsButton Then
            ' Create and display a define_constraints_form dialog (dialog B)
            Dim define_constraints_form = New Define_Constraints()
            define_constraints_form.Show()
        End If

        If changedBlock = autoButton Then
            MsgBox("autoButton clicked")
        End If

        If changedBlock = colorButton Then
            MsgBox("colorButton clicked")
        End If

        If changedBlock = manualButton Then
            MsgBox("manualButton clicked")
        End If

    End Sub

 

Actually I am just developing the dialogs structure now and the main program code is not added yet.

Regards.

Re: UI.Block buttons clicked unwantedly

Phenom
Phenom

The Radio Box is an Enumeration.  So the dilaog ID (in your case changedBlock) will be same.  In your OnUpdate callback all the if statements will be true.  You need to check for the checked item value.

 

Suresh
Technisites Australia
Production: NX10.0.3 Developing: NX11.0.2.7, NX12.0.2, NX1847,
Development: C++, C# .Net, VB .Net, Python, KF

Re: UI.Block buttons clicked unwantedly

Gears Phenom Gears Phenom
Gears Phenom

@robot139are you using a Radio Box? This could be the problem.

Maybe you could post the DLX file too.

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | KF
Production: [NX8.5.3.3 MP11 64bit] Testing: [NX12.0.2 MP1]

Re: UI.Block buttons clicked unwantedly

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

I don't see a Radio Box nor the need for a DLX file when using Snap.UI.BlockForm dialogs.

But without seeing the whole code and exact steps, others can only make assumptions here and I could not see this problem with the following codes either.

 

MyDialogA.vb

 

Option Infer On
Imports Snap, Snap.Create

Public Class MyDialogA : Inherits Snap.UI.BlockForm

    Dim constraintsButton As UI.Block.Button
    Dim autoButton As UI.Block.Button
    Dim colorButton As UI.Block.Button
    Dim manualButton As UI.Block.Button

    Public Sub New()

        Me.Title = "MyDialogA"

        constraintsButton = New UI.Block.Button("Constraints")
        autoButton = New UI.Block.Button("Auto")
        colorButton = New UI.Block.Button("Color")
        manualButton = New UI.Block.Button("Manual")

        Me.AddBlocks(constraintsButton, autoButton, colorButton, manualButton)

    End Sub

    Public Shared Sub Main()

        Dim myFormA = New MyDialogA()
        myFormA.Show()

    End Sub

    Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)

        If changedBlock = constraintsButton Then
            ' Create and display a define_constraints_form dialog (dialog B)
            Dim myFormB = New MyDialogB()
            myFormB.Show()
        End If

        If changedBlock = autoButton Then
            MsgBox("autoButton clicked")
        End If

        If changedBlock = colorButton Then
            MsgBox("colorButton clicked")
        End If

        If changedBlock = manualButton Then
            MsgBox("manualButton clicked")
        End If

    End Sub

    Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer
        Dim unloadOption As Integer
        unloadOption = Snap.UnloadOption.Immediately       ' After executing
        Return unloadOption
    End Function

End Class

MyDialogB.vb

 

Option Infer On
Imports Snap, Snap.Create

Public Class MyDialogB : Inherits Snap.UI.BlockForm

    Dim integerBlock As UI.Block.Integer

    Public Sub New()
        Me.Title = "MyDialogB"
        integerBlock = New UI.Block.Integer("Enter number")
        Me.AddBlocks(integerBlock)
    End Sub

    Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)

        If changedBlock = integerBlock Then
            InfoWindow.WriteLine("You entered " & integerBlock.Value.ToString())
        End If

    End Sub

End Class

 

 

Re: UI.Block buttons clicked unwantedly

Legend
Legend

Hi experts

Thanks for your time.

I have no DLX and I have an enumeration on dialog B.

Here is my complete code:

Option Infer On
Imports Snap, Snap.Create, Snap.NX.ObjectTypes

Public Class dialog_A : Inherits UI.BlockForm

    ' Declarations of the blocks on a dialog_A dialog

    Dim pointSelector As UI.Block.SelectObject
    Dim curveSelector As UI.Block.SelectObject

    Dim button_A1, button_A3, button_A2, button_A4 As UI.Block.Button
    Dim sep As UI.Block.Separator

    Public Sub New()

        Me.Title = "Dialog A"
        Me.Cue = "Please enter information"

        ' Create a point selection block
        pointSelector = New UI.Block.SelectObject("select points", "Select Points")
        pointSelector.BeginGroup = True
        pointSelector.SetFilter(Type.Point)
        pointSelector.AllowMultiple = True

        '-- Create first curve selection block
        curveSelector = New UI.Block.SelectObject("select lines or arcs", "Select Curves")
        curveSelector.BeginGroup = True
        curveSelector.SetFilter(Type.Arc, Type.Line)
        curveSelector.AllowMultiple = True

        ' Create button
        button_A1 = New UI.Block.Button("button_A1")

        ' Create button
        button_A2 = New UI.Block.Button("button_A2")

        ' Create button
        button_A3 = New UI.Block.Button("button_A3")

        ' Create button
        button_A4 = New UI.Block.Button("button_A4")

        sep = New UI.Block.Separator()

        ' Add the blocks to the BlockForm
        Me.AddBlocks(pointSelector, curveSelector, button_A1, button_A2, button_A3, button_A4)

    End Sub

    Public Shared Sub Main()

        ' Create and display dialog_A
        Dim myForm = New dialog_A()
        myForm.Show()

    End Sub

    Public Overrides Sub OnShow()
        ' Code for when dialog is displayed
    End Sub

    Public Overrides Sub OnOK()
        ' Code for when user clicks OK
    End Sub

    Public Overrides Sub OnApply()
        ' Code for when user clicks Apply
    End Sub

    Public Overrides Sub OnCancel()
        ' Code for when user clicks Cancel
    End Sub

    Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)

        If changedBlock = button_A1 Then
            ' Create and display a dialog_B dialog
            Dim dialog_B = New dialog_B()
            dialog_B.Show()
        End If

        If changedBlock = button_A2 Then
            MsgBox("button_A2 clicked")
        End If

        If changedBlock = button_A3 Then
            MsgBox("button_A3 clicked")
        End If

        If changedBlock = button_A4 Then
            MsgBox("button_A4 clicked")
        End If

    End Sub

End Class
Option Infer On
Imports Snap, Snap.Create, Snap.NX.ObjectTypes


Public Class dialog_B : Inherits UI.BlockForm
    Dim testButton As UI.Block.Button
    Dim curveSelector1, curveSelector2 As UI.Block.SelectObject
    Dim menuBlock As UI.Block.Enumeration
    Dim button_B1, button_B2 As UI.Block.Button


    Public Sub New()

        Me.Title = "Dialog B"
        Me.Cue = "Please enter information"

        ' Create an option menu block
        menuBlock = New UI.Block.Enumeration()
        menuBlock.BeginGroup = True
        menuBlock.Label = "type"
        menuBlock.Items = {"type 1", "type 2", "type 3", "type 4"}
        menuBlock.PresentationStyle = UI.Block.EnumPresentationStyle.OptionMenu
        menuBlock.Layout = UI.Block.Layout.Horizontal

        '-- Create first curve selection block
        curveSelector1 = New UI.Block.SelectObject("select line or arc", "Select First Curve")
        curveSelector1.BeginGroup = True
        curveSelector1.SetFilter(Type.Arc, Type.Line)
        curveSelector1.AllowMultiple = False

        '-- Create second curve selection block
        curveSelector2 = New UI.Block.SelectObject("select line or arc", "Select Second Curve")
        curveSelector2.BeginGroup = True
        curveSelector2.SetFilter(Type.Arc, Type.Line)
        curveSelector2.AllowMultiple = False

        ' Create button
        button_B1 = New UI.Block.Button("button_B1")

        ' Create button
        button_B2 = New UI.Block.Button("button_B2")

        Me.AddBlocks(menuBlock, curveSelector1, curveSelector2, button_B1, button_B2)
    End Sub


    'Public Shared Sub Main()
    'End Sub

    Public Overrides Sub OnApply()
    End Sub

    Public Overrides Sub OnUpdate(changedBlock As UI.Block.General)
        If changedBlock = button_B1 Then
            Dim curves1 = curveSelector1.SelectedObjects
            Dim curves2 = curveSelector2.SelectedObjects

            MsgBox("button_B1 clicked")
        End If

        If changedBlock = button_B2 Then
            MsgBox("button_B2 clicked")
        End If

    End Sub

End Class
Public Class Unload

    Public Shared Function GetUnloadOption(ByVal dummy As String) As Integer
        Dim unloadOption As Integer
        unloadOption = Snap.UnloadOption.Immediately       ' After executing
        'unloadOption = Snap.UnloadOption.AtTermination     ' When NX session terminates
        'unloadOption = Snap.UnloadOption.Explicitly        ' Using File-->Unload
        Return unloadOption
    End Function

End Class

 

And this little video shows my problem:

 

(view in My Videos)

 

As you see in the video when I click OK on dialog B and come back to dialog A all of the buttons on dialog A are clicked one by one.

Any help is apreciated.

Thanks.

Re: UI.Block buttons clicked unwantedly

Legend
Legend

Hi everyone

I found a workaround by trial and error.

In my OnUpdate sub instead of

If changedBlock = button_A1 Then

I used:

If changedBlock.NXOpenBlock.Tag = button_A1.NXOpenBlock.Tag Then

 

Regards

Re: UI.Block buttons clicked unwantedly

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

Yes, I was now also able to see this wrong behavior in NX12.0.2 and once I hit this issue then the second dialog was even shown when clicking ANY of the first dialog.

But it works fine for me in NX1847 so I believe it had been fixed already and your workaround for NX12.0.2 by comparing the Tag seems to do the trick, as well.

 

 

 

Re: UI.Block buttons clicked unwantedly

Gears Phenom Gears Phenom
Gears Phenom

I think I know what the problem is now.

We found that in NX12 if you have two block dialogs and open the second block dialog from the first, when you return to the first dialog all of the blocks have lost their names (i.e. calling myButton.name() returns "").

I'm guessing that when you compare blocks in SNAP, internally it is comparing the names of the blocks using block.name(). When all the blocks return "" as their name they all match each other!

I opened an IR that got converted to PR9108453  on this issue. This is stated as fixed in NX1847, but I haven't got that installed yet to try it out.

We don't use SNAP, so we have separate DLX files, but I guess the same problem would affect SNAP too as it is only a wrapper around VB. @Yamada would be able to confirm this.

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | KF
Production: [NX8.5.3.3 MP11 64bit] Testing: [NX12.0.2 MP1]