How does the MessageView control work?

Post

Posted
Rating:
#1 (In Topic #572)
Avatar
Regular
stevedee is in the usergroup ‘Regular’
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;

Code (gambas)

  1.   MessageView1.Border = True
  2.   MessageView1.Open("My 1st message")
  3.   MessageView1.Open("My 2nd message")
  4.   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.
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Enthusiast
PJBlack is in the usergroup ‘Enthusiast’
didn't get it to work :(

but maybe …

Code (gambas)

  1. MessageView1.Border = True
  2. MessageView1.Open("My 1st message")
  3. MessageView1.Close
  4. MessageView1.Open("My 2nd message")
  5. MessageView1.Close
  6. MessageView1.Open("My 3rd message")
  7. MessageView1.Close
  8.  
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Guru
cogier is in the usergroup ‘Guru’

PJBlack said

didn't get it to work :(

Nor me, came up with a similar solution.
Online now: No Back to the top

Post

Posted
Rating:
#4
Guru
BruceSteers is in the usergroup ‘Guru’
i had a play.

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

Code (gambas)

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

possibly a bug worth reporting?

the control passes the optional icon argument like this ..

Code (gambas)

  1.   $hIcon = Icon
  2.   If Not Icon Then
  3.     Try $hIcon = Picture["icon:/32/warning"]
  4.     If Error Then $hIcon = Picture["img/32/warning.png"]
  5.  

that looks okay to me.

the line that fails is in DoOpen()

Code (gambas)

  1.  $H = Max($hIcon.H + Desktop.Scale * 2, Me.Font.RichTextHeight($sText, GetTextWidth()) + Desktop.Scale * 4)
  2.  

the Warning icon shows if no icon argument is given so where it's going wrong i have no idea :-\
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Regular
stevedee is in the usergroup ‘Regular’

BruceSteers said

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.
Online now: No Back to the top

Post

Posted
Rating:
#6
Guru
BruceSteers is in the usergroup ‘Guru’

stevedee said

BruceSteers said

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..

Code (gambas)

  1.  
  2. Private $aText As New String[]
  3.  
  4.  

comp/src/gb.form/.src/Message/MessageView.class · master · Gambas / gambas · GitLab

BruceS
Online now: No Back to the top

Post

Posted
Rating:
#7
Avatar
Regular
stevedee is in the usergroup ‘Regular’

BruceSteers said

…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
Online now: No Back to the top

Post

Posted
Rating:
#8
Guru
BruceSteers is in the usergroup ‘Guru’

stevedee said

BruceSteers said

…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.
Fix MessageView.class (acde2619) · Commits · Bruce Steers / gambas · GitLab

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

Code (gambas)

  1.  
  2.  If Me.Visible Then
  3.    
  4.     $aText.Add(Text)
  5.     $aIcon.Add(Icon)
  6.     UpdateButton
  7.     Return
  8.  
  9.  
  10.  

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.
Online now: No Back to the top

Post

Posted
Rating:
#9
Avatar
Regular
stevedee is in the usergroup ‘Regular’

BruceSteers said


Bruce you are a star!

Many thanks for taking the time to look at this.
Online now: No Back to the top

Post

Posted
Rating:
#10
Guru
BruceSteers is in the usergroup ‘Guru’

stevedee said

BruceSteers said


Bruce you are a star!

Many thanks for taking the time to look at this.

Happy to help <EMOJI seq="1f60e" tseq="1f60e">😎</EMOJI>
The commit has been merged already so its all fixed now <EMOJI seq="1f60a" tseq="1f60a">😊</EMOJI>
I'm happy I've helped you and saved Ben a little time. All is good <EMOJI seq="1f642" tseq="1f642">🙂</EMOJI>
Online now: No Back to the top

Post

Posted
Rating:
#11
Guru
BruceSteers is in the usergroup ‘Guru’

BruceSteers said

stevedee said

BruceSteers said

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..

Code (gambas)

  1.  
  2. Private $aText As New String[]
  3.  
  4.  

comp/src/gb.form/.src/Message/MessageView.class · master · Gambas / gambas · GitLab

BruceS

You could probably import the MessageView.class file into your app, give it a different name so not to conflict and make the message list $aText[] public.

Or if you think it a valuable feature I could submit another change to Ben that gave access to the message list.
Wouldn't be much code.

Wishing well
Bruce
Online now: No Back to the top

Post

Posted
Rating:
#12
Avatar
Regular
stevedee is in the usergroup ‘Regular’

BruceSteers said

…if you think it a valuable feature I could submit another change to Ben that gave access to the message list….

Hi Bruce,
it was only because I screwed up by NOT using the help example that I started down the road of looking at the MessageView using the Object Inspector. Not recognising the real problem, I was simply wondering how it was structured.

It seems to me that it works just fine by passing each message using MessageView.Open().

Initially, I thought this looked like an interesting control. But at the moment I can't think of a single situation were I would want to use it.

For most of my programs I've used the simple Message box where I needed a user to respond, an 'old school' status label where I wanted to keep the user informed, or a ListBox where I thought it useful to have a simple viewable on-screen log of recent events or other issues.

The idea of stacking up a number of messages in a MessageView that a user has to deal with, no longer seems that useful. But I would be interested if anyone can think of a good use for it.

Thanks once again for your help.

Up until now there has been a bit of a gap between us users on this forum, and the Gambas devs.

You are a great asset for GambasOne as you bridge that gap by looking into the Gambas code, shaking a few trees and taking the time to explain how things work (…or don't work). I just hope you don't get bored with us, and move on!

Stay safe over there on the Diamond Isle.

Steve
Online now: No Back to the top

Post

Posted
Rating:
#13
Avatar
Enthusiast
PJBlack is in the usergroup ‘Enthusiast’

stevedee said

You are a great asset for GambasOne as you bridge that gap by looking into the Gambas code, shaking a few trees and taking the time to explain how things work (…or don't work). I just hope you don't get bored with us, and move on!

Stay safe over there on the Diamond Isle.

Steve

from here also a BIG thank you :)
Online now: No Back to the top

Post

Posted
Rating:
#14
Guru
BruceSteers is in the usergroup ‘Guru’

stevedee said

BruceSteers said

…if you think it a valuable feature I could submit another change to Ben that gave access to the message list….

Hi Bruce,
it was only because I screwed up by NOT using the help example that I started down the road of looking at the MessageView using the Object Inspector. Not recognising the real problem, I was simply wondering how it was structured.

It seems to me that it works just fine by passing each message using MessageView.Open().

Initially, I thought this looked like an interesting control. But at the moment I can't think of a single situation were I would want to use it.

For most of my programs I've used the simple Message box where I needed a user to respond, an 'old school' status label where I wanted to keep the user informed, or a ListBox where I thought it useful to have a simple viewable on-screen log of recent events or other issues.

The idea of stacking up a number of messages in a MessageView that a user has to deal with, no longer seems that useful. But I would be interested if anyone can think of a good use for it.

The gambas IDE uses it, a running app throws error messages to it and they appear at the top of the window. Or it used to, can't say I have seen it much recently.

I can see uses for it but i also see a use in accessing the message list.
for example something like this if there's been 50+ messages…

Code (gambas)

  1. If MessageView1.Messages.Count > 50 And If Not bReadAll Then
  2. iRes = Message.Warning("There are 50+ messages", "Close All", "Read Vital", "Read All")
  3.  
  4.   If iRes = 1 Then
  5.    MessageView1.Close()
  6.   Else If iRes = 2 Then
  7.     For c As Integer = MessageView1.Messages.Count-1 To 0 Step -1
  8.      If Not MessageView1.Messages[c] Begins "Vital:" Then MessageView1.Messages.Remove(c)
  9.     Next
  10.   Else If iRes = 3 Then
  11.     bReadAll = True
  12.     Return
  13.  

I definitely see an advantage in being able to access the message count and removing unwanted messages if needed

stevedee said

Thanks once again for your help.

Up until now there has been a bit of a gap between us users on this forum, and the Gambas devs.

You are a great asset for GambasOne as you bridge that gap by looking into the Gambas code, shaking a few trees and taking the time to explain how things work (…or don't work). I just hope you don't get bored with us, and move on!

Stay safe over there on the Diamond Isle.

Steve

aaw , cheers Steve
Like i say I just love to help out.
Sometimes give the help , sometimes I get the help :) Cest la vie

Funny I was thinking the same about you when i was deliberating how i might ask Benoit about the changes to this class you wanted. I thought to mention it was requested by a chap who is also a great asset to Gambas on the GambasOne forum with his own captainbodgit web page with many gambas examples. Has been a great help to me and many others I'm sure.

So right back at ya my friend.
Stay safe and be well :)
Bruce
Online now: No Back to the top

Post

Posted
Rating:
#15
Guru
BruceSteers is in the usergroup ‘Guru’

PJBlack said

stevedee said

You are a great asset for GambasOne as you bridge that gap by looking into the Gambas code, shaking a few trees and taking the time to explain how things work (…or don't work). I just hope you don't get bored with us, and move on!

Stay safe over there on the Diamond Isle.

Steve

from here also a BIG thank you :)

And thank you Michael :)
I think you are the only person who actually uses my gambas updater apps  :lol:
I appreciate your bug reports/suggestions , I can't find them all myself.

Wishing well
Bruce
Online now: No Back to the top

Post

Posted
Rating:
#16
Avatar
Enthusiast
PJBlack is in the usergroup ‘Enthusiast’
 can't believe that bruce … everybody who deals with x.x.90 should use it
Online now: No Back to the top
1 guest and 0 members have just viewed this.