Hi,
I'm working on a new macro where I want the window to be separate from the TBC window but the viewport still accessible. It'll contain a rather large table, hence I don't want it squeezed into the usual place and also still easy access to a second macro window. I know that I can float that dock. But I'd prefer to have my window completely separate. Until I find a solution to the conundrum that I maneuvered myself into, I'll have to use the normal float solution.
The sample macros "ListProjectObjects" and "ViewProjectData" show how to create a modal window where you can't interact with TBC anymore
def Setup(cmdData, macroFileFolder):
#cmdData.UIForm = "SCR_Inspect12dAttributes" # must be disabled
def Execute(cmd, currentProject, macroFileFolder, parameters):
form = ListProjectObjectsDialog(currentProject, macroFileFolder).ShowDialog()
return
class ListProjectObjectsDialog(Window): # this inherits from the WPF window control
def __init__(self, currentProject, macroFileFolder):
with StreamReader(macroFileFolder + r"\ListProjectObjects.xaml") as s:
wpf.LoadComponent(self, s)
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
Title="Objects in Project" Height="400" Width="400" MinHeight="100" MinWidth="200">
<Grid Margin="0,0,0.2,-0.2" >
If you change
def Execute(cmd, currentProject, macroFileFolder, parameters):
form = ListProjectObjectsDialog(currentProject, macroFileFolder).ShowDialog()
to
def Execute(cmd, currentProject, macroFileFolder, parameters):
form = SCR_Inspect12dAttributesDialog(currentProject, macroFileFolder).Show()
return
# .Show() - is non modal - you can interact with the drawing window
# .ShowDialog() - is modal - you CAN NOT interact with the drawing window
the window will be floating and the user can still select objects on the screen.
BUT, here comes the catch, textboxes or datagrids won't get keyboard entries anymore. They go into edit mode, and you can drag characters around with the mouse, but it completely ignores the keyboard.
First I thought my DataGrid implementation is wrong and it drove me nuts for hours. (({..})) Until I had the epiphany to switch the window back to modal, and it suddenly worked. (headbang)
This is not a TBC bug. Once I found the actual reason I did find forum entries that suggest that this is a WPF bug, or at least shortcoming.
They suggest to call "EnableModelessKeyboardInterop" from the application that is creating the window, which would be TBC itself.
Has anybody tried that kind of modeless window before and found a workaround for the ignored keyboard?
I did find the entry "UIViewForm" while inspecting the variable cmdData during startup.
If I set
def Setup(cmdData, macroFileFolder):
cmdData.UIViewForm = "SCR_Inspect12dAttributes"
class SCR_Inspect12dAttributes(Grid):
I end up with an extra tab besides the plan view. Not too bad, but I need to find out how to float that one. Right click in that view doesn't show "Float".
------------------------------
Ronny Schneider
------------------------------