Hi,
All my sheet windows have the following code in their open event:
WindowIsOpen = True
And the following code in their close event:
WindowIsOpen = False
In my main window I have the following code in the ConstructContextualMenu event
[code] If WindowIsOpen = False Then
Dim row As Integer = Me.RowFromXY(X, Y)
If row > -1 Then
base.append(New MenuItem("Create New Good Entry"))
base.append(New MenuItem("Create New Bad Entry"))
base.append(New MenuItem("Edit / Delete Selected Entry"))
Return True
else
base.append(New MenuItem("Create New Good Entry"))
base.append(New MenuItem("Create New Bad Entry"))
end if
else
Return True
End if
Return True[/code]
The problem is that the property WindowIsOpen does not seem to be getting set to True, because if I right click and then open a window - I can then right click again and open another window.
Can anyone tell me why the right click continues to work (even though the property is set to true)?
Its a bug. There are problems with the contextual menus. I had this same issue and ended up creating my own classContextualMenu because I spent days debugging only to find there were problems. Its easy to use, here we go https://github.com/CharlieXojo/classContextualMenu
Here was my discussion on the issue I had and very similar to what you describe above - Forum Post
I understand it has been fixed for the next release but if you cant wait, try my solution above.
[code]
Function ConstructContextualMenu(base as MenuItem, x as Integer, y as Integer) As Boolean
If WindowIsOpen = False Then
base.append(New MenuItem("Create New Good Entry"))
base.append(New MenuItem("Create New Bad Entry"))
base.append(New MenuItem("Edit / Delete Selected Entry"))
Return True
else
Return True
End if
End Function[/code]
[code]
Function ContextualMenuAction(hitItem as MenuItem) As Boolean
dim w as new Window2
w.showmodalwithin(self)
End Function[/code]
create a new module (module1) with a global property
WindowIsOpen As boolean
create new sheet window (window2)
Sub Open()
WindowIsOpen = true
End Sub
Sub Close()
WindowIsOpen = false
End Sub[/code]
add a bevel button to window with this as its action event
[code]Sub Action()
self.close
End Sub
I think the only difference is that you apparently had this in a listbox as there was the code for row from xy
Are you talking about windows with their Frame property set to “Sheet Window”? Then you have to open them in your code with Window.ShowModalWithin. In addition you then probably also can get rid of the property WindowIsOpen.
[quote=118794:@Richard Summers]The problem is that the property WindowIsOpen does not seem to be getting set to True, because if I right click and then open a window - I can then right click again and open another window.
Can anyone tell me why the right click continues to work (even though the property is set to true)?[/quote]
Eli - I have tried various combinations of your recommendation above - none of which work:
AddWindow.ShowModal
AddWindow.ShowModalWithin
AddWindow.ShowModalWithin()
AddWindow.ShowModalWithin(self)
AddWindow.ShowModalWithin(Window1)
I either get the error: This method requires more parameters than were passed. or This Item Does Not Exist.
It is obviously the bug which everyone is talking about - so I will have to remove the contextual menu completely, and try Mike’s solution.
thanks for trying to help - much appreciated.