F1 Help for addin only, using WPF

F1 Help for addin only, using WPF

hsaATnti_dk
Participant Participant
1,783 Views
10 Replies
Message 1 of 11

F1 Help for addin only, using WPF

hsaATnti_dk
Participant
Participant

Hi

I'm implementing a custom context dependent help in our Revit addins (based on WPF, using C#). I catch the user pressing 'F1' and react on that, but face the problem that Revit always starts my internet browser showing the Revit help page when 'F1' is pressed. This happens even if i catch the KeyDown and PreviewKeyDown events and set 'Handled' to true and even if the active window is shown using ShowDialog().

I am aware of the solution working for Windows Forms:

https://thebuildingcoder.typepad.com/blog/2018/03/contextual-help-best-practice.html.

but I have not found a working solution for WPF. (Wouldn't it be nice if Revit just respected the event 'Handled' property?)

 

Regards Henrik

0 Likes
1,784 Views
10 Replies
Replies (10)
Message 2 of 11

Chuong.Ho
Advocate
Advocate

some thing like that, same same .Use it with previewkeydown in wpf

private void HandleEsc(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Escape)
                Close();
        }

#Event Hander 
this.PreviewKeyDown += new KeyEventHandler(HandleEsc);

 

Chuong Ho

EESignature

0 Likes
Message 3 of 11

hsaATnti_dk
Participant
Participant

Hi, thanks for your reply.

 

The question is not about catching the keydown event. My eventhandler looks like this:

private void ConnectWindow_PreviewKeyDown(object sender, KeyEventArgs e)
{
    switch (e.Key)
    {
        case Key.F1:
            e.Handled = true;
            ShowHelp();
            break;
        default:
            break;
    }
}

 The problem is that Revit always opens its own help-page in my browser when user presses F1 even though I set 'handled' to true.

 

Regards

/Henrik

0 Likes
Message 4 of 11

Chuong.Ho
Advocate
Advocate
I'm used ContextualHelp in RevitAPIUI, but it's working with when you drag to button and click f1.

 

Chuong Ho

EESignature

0 Likes
Message 5 of 11

hsaATnti_dk
Participant
Participant
We use that too. Still we also want to offer help pressing F1 inside our own windows.
0 Likes
Message 6 of 11

Chuong.Ho
Advocate
Advocate

You need to set owner form that prior set event previewkeydown

https://github.com/chuongmep/RevitElementBipChecker/blob/ba885c6b04bda5fd147107759aa7aca5ecd83d1f/Co...

Chuong Ho

EESignature

0 Likes
Message 7 of 11

RPTHOMAS108
Mentor
Mentor

I tried pressing F1 in a WPF windows Revit 2022 but nothing happened (I didn't create any contextual help implementation for the ribbon item).

 

Is this an issue specific to using the ContextualHelp class i.e. did you use it for a ribbon item and you find it caries through to the Window being shown?

 

The ContextualHelp.HelpType is either None/ContextId/Url/ChmFile setting to None probably provides default behaviour perhaps. ContextualHelp.Launch can be called anytime.

 

 

0 Likes
Message 8 of 11

hsaATnti_dk
Participant
Participant

My question has nothing to do with the ribbon or the ContextualHelp class. Put simple:

  1. Open a WPF window with ShowDialog()
  2. Press F1: Revit opens its 'Help Home' page in my default browser. I don't want that to happen.

I'm surprised that you did not experience this when pressing F1. I se it in all Revit versions 2017 - 2022.

 

0 Likes
Message 9 of 11

RPTHOMAS108
Mentor
Mentor

That's odd the F1 key does nothing when I show a WPF window (Revit 22.0.10.28, 2022.0.1).

0 Likes
Message 10 of 11

landis.mark
Contributor
Contributor

Has anyone solved this problem? I am working on my first Revit add-in and need to implement Contextual Help.

 

 

0 Likes
Message 11 of 11

hsaATnti_dk
Participant
Participant

Hi

 

Unfortunately we never found a solution for this. 😞

 

Regards Henrik

0 Likes