Jump to content
LaunchBox Community Forums

Add clickable hyperlinks to Custom Fields


JoeViking245

Recommended Posts

I wanted a way to have a clickable link in LaunchBox to the Internet Pinball Database (IPDB) for each of my Visual Pinball tables. (i.e. https://www.ipdb.org/machine.cgi?id=760 “Eight Ball”).  I had thought about putting the links in the Wiki or YouTube fields, but it was kind of ugly.

Messing around, I found a way that allowed me to right-click a Custom Field and select "Go to webpage".  It opens the default internet browser to whatever hyperlink page is in the Custom Field.  Note: this will only work with LaunchBox Premium as the free version doesn't show Custom Fields.

For my VPX platform, I also added a custom field for "Table" that would hold a link to the tables’ webpage.  (to look for updates or whatever reason)

Obviously, you can name the Custom Field anything you want for any circumstance. For any platform.

The only pain is entering the hyperlink(s) for each table (or game) individually.

image.thumb.png.36ce1db7997dad422634332697597a6f.png

(Pict of Right-Clicking the IPDB link.)

 

To make this work, I needed to modify the GameDetailsView.xaml located in the Views folder of the LaunchBox theme.   

Here’s what I did.

Summary:

  • Insert 2 lines of code
  • Comment out 1 line of existing code
  • Insert 1 code block

I'll use @faeran's "Default Plus" theme as an example.  First, create a copy of the theme’s main folder and then open the GameDetailsView.xaml file (in the copied folder) in Notepad++.  (Any text editor will work. I used Notepad++ to make it easy to reference line numbers)

D:\LaunchBox\LBThemes\Default Plus - Copy\Views\GameDetailsView.xaml

 

Below the last "xmlns" entry (line 10) insert a new line.  (here, we're adding a new reference and calling it "web")

xmlns:web="clr-namespace:Unbroken.LaunchBox.Windows.Desktop.Commands;assembly=LaunchBox"

 

Just before the closing of "UserControl.Resources" (line 34 [after inserting the above]), inset a new line. 

<web:WebLinkCommand x:Key="WebCommand" />

(Here we're creating a static resource which we're calling "WebCommand".)  Indents don't matter. But it looks prettier.

 

So far, it looks like this:

image.thumb.png.fe2277b19e91ffb66f5a71c136b642a3.png

 

 

Now search for and go to CustomFields (or scroll to line 1334 [after inserting the above 2 lines]).  A few lines down, click once on the 2nd <TextBlock... line.  (line 1345)  This is the line that contains Text="{Binding Value}"  Press Ctrl+K (Notepad++) to comment out that line.  (That may only work because of a plugin I installed. Don't recall.  Alternately, add <!-- to the beginning of the line, and --> to the end).

<!-- <TextBlock Grid.Column="2" Text="{Binding Value}" Foreground="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.ForegroundBrush}" TextWrapping="Wrap" TextAlignment="Right" /> -->

 

Below this [now] commented line, insert the following:

<TextBlock Grid.Column="2" Text="{Binding Value}" Foreground="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.ForegroundBrush}" TextWrapping="Wrap" TextAlignment="Right" >
    <TextBlock.ContextMenu>
        <ContextMenu>
            <MenuItem Command="{StaticResource WebCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=TextBlock}, Path=Text}">
                <MenuItem.Header>
                    <TextBlock Text="Go to webpage" HorizontalAlignment="Center"/>
                </MenuItem.Header>
            </MenuItem>
        </ContextMenu>
    </TextBlock.ContextMenu>
</TextBlock>

Here we're replacing the original TextBlock with a new one that lets us right-click.  If you want it to say something other than “Go to webpage” when you right-click, just replace the part in quotes (Text="Go to webpage"). (Line 1351)

Here's what the whole CustomFields section will look like

image.thumb.png.924f8f988840e4a970ff6f40698b4a9f.png

Save and close.  Tell LB to use this theme. 

 

Caveat:

If you have a custom field that's not a hyperlink or is an invalid link and you right-click and select "Go...", you'll get a message box telling you it's an invalid URL.  So just don’t do that.  ;) 

  • Like 2
  • Game On 1
Link to comment
Share on other sites

  • 1 year later...
25 minutes ago, rexryan said:

Is this still the way to do links or is there an updated way?

I don't know if it's the way to do links. But it is a way. :D

I just tested my old theme in which I had experimented on (a copy of Default Plus), and it still works.  Which leads me to believe there's no reason it won't work on others themes as well.

  • Thanks 1
Link to comment
Share on other sites

On 11/10/2024 at 2:14 PM, JoeViking245 said:

I don't know if it's the way to do links. But it is a way. :D

I just tested my old theme in which I had experimented on (a copy of Default Plus), and it still works.  Which leads me to believe there's no reason it won't work on others themes as well.

Worked like a champ..Thanks have you ever tried to get it to work in BB?

Link to comment
Share on other sites

16 minutes ago, rexryan said:

Worked like a champ..Thanks have you ever tried to get it to work in BB?

Glad to hear after almost 2 years later someone actually tried this and it working! :D

Never thought to try it in BigBox.  TBH, don't think I've ever used a mouse in BB.  Keyboard navigation (cab buttons), yeah.  Controller, of course.

 

Link to comment
Share on other sites

1 hour ago, rexryan said:

Controller option is where im going..If you come up with something would be awesome

Yeah, that'd require a plugin to capture the controller input.  Then you'd navigate away from BigBox.  And then you have to grab your mouse and keyboard to continue navigation in wherever the link sent you.  Since you have to grab the mouse anyway, may as well grab it early and right-click the link in BB. ;)  (Assuming the mouse right-click capture works in BB.)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...