B4J Question About Message Box with Link

rfresh

Well-Known Member
Licensed User
Longtime User
I would like to put a web link in my dialog message box. Does the default message dialog box support that capability?

B4X:
Dim str0 As String
   
str0 = $"About

Here is a link for more help:

https://www.youtube.com/watch?v=xn260L

"$
    fx.Msgbox(MainForm,str0,"About")
 

rfresh

Well-Known Member
Licensed User
Longtime User
Thank you.

UPDATE
I got the new dialog window working when I select my menu item. I created a new layout (CustomDialog). The dialog window pops up fine. I'm just not sure how to add the URL link to the CustomDialog layout?
 
Last edited:
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
I saw there is a URL tag. What component do I add that to in BBCodeView?

B4X:
[url="https://www.google.com/"]Here's my link[/url]
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Full example:
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    DialogPanel = xui.CreatePanel("")
    DialogPanel.SetLayoutAnimated(0, 0, 0, 300dip, 200dip)
    DialogPanel.LoadLayout("Dialog")
    Dialog.Initialize(Root)
    TextEngine.Initialize(Root)
    DialogCodeView.TextEngine = TextEngine
    #if B4J
    Dim sp As ScrollPane = DialogCodeView.sv
    sp.SetVScrollVisibility("NEVER")
    #end if
End Sub

Sub Button1_Click
    TextEngine.TagParser.UrlColor = Dialog.ButtonsTextColor
    DialogCodeView.Text = $"[color=white]j fskldfj lksdfj lksdfj lskdf lkslkdf slkdfj sdlkfj slkdf
sdklfjslkdf jslkdfj lksdf jklsdf lksdf
qwdqwd

[url=https://www.google.com]Click here[/url][/color]"$
    DialogPanel.Height = DialogCodeView.Paragraph.Height + 40dip
    Wait For (Dialog.ShowCustom(DialogPanel, "Yes", "No", "Cancel")) Complete (Result As Int)
End Sub

Private Sub DialogCodeView_LinkClicked (URL As String)
    Dialog.Close(xui.DialogResponse_Cancel)
    Dim fx As JFX
    fx.ShowExternalDocument(URL)
End Sub

You can customize the dialog style in any way you like.
 

Attachments

  • Project.zip
    9.7 KB · Views: 262
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
Thank you Erel but this is over my head to understand what's going on and add it to my code. I worked two hours and could not get a clean compile. Your zip file contained much more code than what you posted in the CODE blocks. I have no idea what code to pull out of your zip example and integrate into my own code. I tried just adding your CODE blocks example but always got errors. So I just gave up after two hours.

For someone like you and many others here, this wouldn't be difficult to implement, but for me, not being as experienced, it's too much code to integrate into my own code just to get a clickable link. To get this simple capability, (a clickable link), there is a huge amount of code to bring along. In the end, I'll have to leave out the ability to click a link.

Thank you again for trying to help me.

 
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
I pasted your code again. I put the following into Process_Globals

B4X:
    Private Root As B4XView
    Private xui As XUI
    Private DialogCodeView As BBCodeView
    Private dialog As B4XDialog
    Private DialogPanel As B4XView
    Private TextEngine As BCTextEngine

When I click on my About menu I get this error:

B4X:
java.lang.NullPointerException
    at b4j.fplfms.main$ResumableSub_about_Action.resume(main.java:194)

I'm not sure what it means.
 
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
dialog.zip file is attached.

There is one error on line 52.

The program has to click on the About menu selection to call up your code to see the link.

Thank you...
 

Attachments

  • dialog.zip
    3.8 KB · Views: 241
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
Dialog Code View.In my AppStart, this line:

B4X:
    DialogCodeView.TextEngine = TextEngine

is giving me the following error:

java.lang.RuntimeException: Class instance was not initialized (bbcodeview)

In your dialog example I could not find where you initialized DialogCodeView.TextEngine so I'm not sure what this error wants.

Thank you...
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…