How does the MessageView control work?

Post your Gambas programming questions here.
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

How does the MessageView control work?

Post by stevedee »

Just out of curiosity, does anyone know how you are supposed to use the MessageView control?

Its not a problem getting it to display a single message, but the help file says;
"Messages are displayed successively, and the message panel is closed only when there is no message to read anymore."

This makes me think it should have a string array associated with it, but if you just write code like this;
  MessageView1.Border = True
  MessageView1.Open("My 1st message")
  MessageView1.Open("My 2nd message")
  MessageView1.Open("My 3rd message")
...it will display the first message along with a "next" button but not show subsequent messages.

Using the Object Inspector does not show were these messages are held within MessageView.
User avatar
PJBlack
Posts: 185
Joined: Tuesday 9th June 2020 10:26pm
Location: Florstadt, Hessen, Germany

Re: How does the MessageView control work?

Post by PJBlack »

didn't get it to work :(

but maybe ...
MessageView1.Border = True
MessageView1.Open("My 1st message")
MessageView1.Close
MessageView1.Open("My 2nd message")
MessageView1.Close
MessageView1.Open("My 3rd message")
MessageView1.Close
User avatar
cogier
Site Admin
Posts: 1125
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: How does the MessageView control work?

Post by cogier »

PJBlack wrote: Wednesday 3rd February 2021 3:05pm didn't get it to work :(
Nor me, came up with a similar solution.
User avatar
BruceSteers
Posts: 1565
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: How does the MessageView control work?

Post by BruceSteers »

i had a play.

It works as expected if you also give the icon argument.

MessageView1.Border = True
MessageView1.Open("My 1st message", Picture["icon:/48/ok"])
MessageView1.Open("My 2nd message", Picture["icon:/48/ok"])
MessageView1.Open("My 3rd message", Picture["icon:/48/ok"])

possibly a bug worth reporting?

the control passes the optional icon argument like this ..
  $hIcon = Icon
  If Not Icon Then 
    Try $hIcon = Picture["icon:/32/warning"]
    If Error Then $hIcon = Picture["img/32/warning.png"]
  Endif
that looks okay to me.

the line that fails is in DoOpen()
 $H = Max($hIcon.H + Desktop.Scale * 2, Me.Font.RichTextHeight($sText, GetTextWidth()) + Desktop.Scale * 4)
the Warning icon shows if no icon argument is given so where it's going wrong i have no idea :-\
Last edited by BruceSteers on Wednesday 3rd February 2021 6:34pm, edited 1 time in total.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

Re: How does the MessageView control work?

Post by stevedee »

BruceSteers wrote: Wednesday 3rd February 2021 6:23pm i had a play.

It works as expected if you also give the icon argument...
Thanks Bruce, I came to the same conclusion about half an hour ago.

I'm still trying to work out where the text is stacked, thought it would be in a Children object.
User avatar
BruceSteers
Posts: 1565
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: How does the MessageView control work?

Post by BruceSteers »

stevedee wrote: Wednesday 3rd February 2021 6:31pm
BruceSteers wrote: Wednesday 3rd February 2021 6:23pm i had a play.

It works as expected if you also give the icon argument...
Thanks Bruce, I came to the same conclusion about half an hour ago.

I'm still trying to work out where the text is stacked, thought it would be in a Children object.
nah looking at the code it's in a private string list..

Private $aText As New String[]
Private $aIcon As New Picture[]

https://gitlab.com/gambas/gambas/-/blob ... View.class

BruceS
If at first you don't succeed , try doing something differently.
BruceS
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

Re: How does the MessageView control work?

Post by stevedee »

BruceSteers wrote: Wednesday 3rd February 2021 6:23pm ...possibly a bug worth reporting?...
The help information is correct, in that it does NOT indicate that the image icon is optional...so my stupidity created the problem. Just surprised that the IDE did not protect me from myself by raising a syntax error. :o
User avatar
BruceSteers
Posts: 1565
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: How does the MessageView control work?

Post by BruceSteers »

stevedee wrote: Wednesday 3rd February 2021 6:42pm
BruceSteers wrote: Wednesday 3rd February 2021 6:23pm ...possibly a bug worth reporting?...
The help information is correct, in that it does NOT indicate that the image icon is optional...so my stupidity created the problem. Just surprised that the IDE did not protect me from myself by raising a syntax error. :o
No it's a bug.

I just submitted a fix for Ben.
https://gitlab.com/bsteers4/gambas/-/co ... e22bcf621a

checking if an icon argument had been passed and setting the default happened "after" this bit of code...

 If Me.Visible Then
    
    $aText.Add(Text)
    $aIcon.Add(Icon)
    UpdateButton
    Return

  Endif

so in that instance the default icon had not been set.
i moved the default icon setting bit to up before that code and changed Icon to $hIcon.
if Ben thinks the fix is good it will soon be all better :)

Bruce.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

Re: How does the MessageView control work?

Post by stevedee »

BruceSteers wrote: Wednesday 3rd February 2021 6:56pm ...No it's a bug.

I just submitted a fix for Ben.
https://gitlab.com/bsteers4/gambas/-/co ... e22bcf621a
Bruce you are a star!

Many thanks for taking the time to look at this.
User avatar
BruceSteers
Posts: 1565
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: How does the MessageView control work?

Post by BruceSteers »

stevedee wrote: Wednesday 3rd February 2021 7:05pm
BruceSteers wrote: Wednesday 3rd February 2021 6:56pm ...No it's a bug.

I just submitted a fix for Ben.
https://gitlab.com/bsteers4/gambas/-/co ... e22bcf621a
Bruce you are a star!

Many thanks for taking the time to look at this.
Happy to help 😎
The commit has been merged already so its all fixed now 😊
I'm happy I've helped you and saved Ben a little time. All is good 🙂
If at first you don't succeed , try doing something differently.
BruceS
Post Reply