Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Contextual help not working from within a command?

16 REPLIES 16
Reply
Message 1 of 17
Anonymous
1152 Views, 16 Replies

Contextual help not working from within a command?

Hi,

 

so Im trying to add contextual help for all commands (press F1 to goto a location).
Its working fine when the tooltip is shown for my commands, but when the dialog is open: pressing F1 opens the Autodesk knowledge site for Revit.


I looked at the documentation here: Ribbon panels and controls and this part:
"The ContextualHelp class has a Launch() method that can be called to display the help topic specified by the contents of this ContextualHelp object at any time, the same as when the F1 key is pressed when the control is active. This allows the association of help topics with user interface components inside dialogs created by an add-in application. "

leads me to believe that one should be able to press F1 from within a command and get the correct contextual help.

 

What am I missing?

Thanks!

/Erik

Tags (1)
16 REPLIES 16
Message 2 of 17
jeremytammik
in reply to: Anonymous

Dear Erik,

 

Thank you for your query.

 

I' checking with the development team for you.

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 17
Anonymous
in reply to: jeremytammik

Hi Jeremy,

 

thanks for that.
Can you confirm that I should expect it to open my contextual help when my modal window is Active?

Message 4 of 17
jeremytammik
in reply to: Anonymous

Dear Erik,

The development team replies:

 

I think this is not quite correct.  The add-in can use the contextual help API to associate and launch a command to open a help page (not necessarily on Autodesk’s site).  But inside their dialog, they will need to interpret F1 button presses and make that happen (by invoking Launch()).  We do not have any control inside of the implementation of their dialog.  At least this is what I think we support. But it is strange to hear that the help jumped to a main Autodesk page – I wouldn’t have expected it to do anything.  Is it a modal or modeless dialog?

Cheers,

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 5 of 17
Anonymous
in reply to: jeremytammik

That was fast.


Its a modal dialog.

 

 

Message 6 of 17
Anonymous
in reply to: Anonymous

Hi again Jeremy,

 

Im still having problems with my contextual help.
Im adding an input binding to my main view that captures the F1button and it all works great. However, the Autodesk helpsite for Revit is also opened. This is not something I want. 
Can that be fixed somehow?

/Erik

Message 7 of 17
jeremytammik
in reply to: Anonymous

Dear Erik,

 

Thank you for your update and sorry to hear this is not yet satisfactorily resolved.

 

I asked the development team for you again.

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 8 of 17

Hi, This seems to be a repeat of my original request:

https://forums.autodesk.com/t5/revit-api-forum/f1-help-for-addin-only/m-p/7522730#M26252

 

I didn't follow this any further, so did not find a resolution.

 

I am adding Help to my addin and want the F1 key to call my help file (CHM) for the whole form, not just for the control that has focus. I am using the following code which is working fine. My problem is that F1 triggers Revit's online help after calling mine. Is there a way to prevent this keystroke going on to Revit? Many thanks. Dale   

 

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            // F1 for help on any control
            if (keyData == (Keys.F1))
            {
                HelpClick();

                // This keystroke was handled, don't pass to the control with the focus
                return true;
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }

 




______________
Yes, I'm Satoshi.
Message 9 of 17
jeremytammik
in reply to: Anonymous

Dear Erik and Dale,

 

Thank you both for your updates and patience.

 

Sorry to hear this is not yet satisfactorily resolved, especially after your report so long ago, Dale.

 

I now submitted a change request for the development team to analyse: REVIT-126882 [ContextualHelp displays Autodesk help in addition to add-in help -- 12806669]. Please make a note of this number for future reference.

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 10 of 17

Thanks Jeremy. Dale




______________
Yes, I'm Satoshi.
Message 11 of 17

Hi @Dale.Bartlett, @Anonymous,

 

Catching F1 presses in modal C# form is normally caught using the HelpRequested Control event, like this:

 

// in designer
this.HelpRequested += new System.Windows.Forms.HelpEventHandler(this.OnHelpRequested);

// in form's code
private void OnHelpRequested(object sender, HelpEventArgs hlpevent)
{
   // Do stuff here, whatever you wish. Once this event is called, Revit no longer follows
   Help.ShowPopup(this, "test help", new Point(somewhere.x, somewhere.y));
}

If the above event is not subscribed to, Revit opens it's help. If it is, Revit does nothing.

Does this solution solve your problem?

 

 



Turmac Dragos
Pr. SW. Engineer
Message 12 of 17

Thank you very much for this explanation, Dragos!

 

I would love to see a minimal sample demonstrating the proper use to share on the blog, if one of you is willing to set one up for us.

 

Thank you!

 

Cheers,

 

jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 13 of 17

Attached a small add-in that only shows a window Form on which an F1 press will show up a test popup help and Revit does nothing about it.



Turmac Dragos
Pr. SW. Engineer
Message 14 of 17

Thanks Dragos/Jeremy,

 

I can confirm that I used your original snippet to call my context Help routine, and all worked perfectly. Many thanks. Dale




______________
Yes, I'm Satoshi.
Message 15 of 17
jeremytammik
in reply to: Anonymous

Preserved for posterity by The Building Coder:

 

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

 

Many thanks again to Dragos for solving and explaining this.

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 16 of 17
michael-coffey
in reply to: Anonymous

Is there an equivalent to the HelpRequested event for a WPF window?

Message 17 of 17

So, you have the .NET event HelpRequested:

 

https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.control.helprequested?view=windowsd...

 

And you are asking whether it is available in WPF.

 

And why, pray, are you asking such a question in the Revit API discussion forum?  🙂

 

It has nothing to do with the Revit API.

 

I hope somebody else knows and can help.

 

I'm afraid I have no idea.

 

Cheers and good luck,

 

Jeremy

 

 

 

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community