On 2020-06-07 08:45, Richard Hainsworth wrote:


Hi Richard,

Some follow questions:

1) where are the directions?
I don't understand this question. Which directions? I tried to make the example as full of explanation as possible.
where are the
variable definitions?
I don't understand this. The variables are all defined.

By directions, I mean the (English) definition of
what each variable does. What do the following do:

:buttons,
:Response,
:timer,
:title,
:show-countdown,
data.response = <$data.response>;
etc.

They may be somewhere there, but I need a link
to them


in the following:

# my first attempt:

first you will need a 'my'. In the example, I put:

my $popup = inform .... etc

As I said, but I expanded in the comments, 'inform' is a subroutine that returns and 'Informing' object.

Actually, this is also a pointer in answer to something you asked elsewhere. This is a way of creating something to which methods are attached.

$popup = inform( 'Something cleaver here',
                 # :buttons(Dismiss => 'Dismiss Test', :Response('Dismissed'))
                 # :buttons(Dismiss => 'Dismiss Test'),
                 # :buttons( OK=>'OK',b2=>'Not on your life', 'Cancel'=> "I don't want to")
                 :buttons( OK=>'OK Maybe', b2=>'Not on your life' ),
                 :timer(5),
                 :title("5 second Countdown test"),
                 :show-countdown );
print( "popup = <$popup>\n" );
print( "data.response = <$data.response>\n" );

The first print should give you something about the Informing object

Note that in the second print, you have invoked the `.response` method on the object. This is used to extract the information from the dialog box. However, you have used '<' which is used inside a "" string for other things. Better to use

print "data response is = < { $popup.response } >";

That has got me into trouble before.  I switched to
     print( "data = <" ~ $popup ~ ">\n" );
     print( "data.response = <" ~ $data.response ~ ">\n" );

     data = <Informative::Informing<81196960>>
     data.response = <Cancel>   # or OK



Also note that you have not defined $data.

oops.

What is with the weird
    data = <Informative::Informing<81196960>>


2) why do I have to have more than one button?
`:buttons( OK=>'OK Maybe' )` errors with

      Type check failed in binding to parameter
      '@buttons'; expected Positional but got Pair
      (:OK("OK Maybe"))

More than one button, possible!

But look at the error message. You have specified `OK => 'string'` which is the definition of a Pair, as the error message says.

But what is wanted is a Positional, as the error message says. An example of a Positional is an Array. So try this

`:buttons( [ :OK("OK Maybe") ] )

The [ ] creates an Array, which is a Positional.


In my example, I gave three Pairs separated by commas. That is interpreted by raku as a Sequence, which is also a Positional.

You could have written

:buttons(:OK("OK Maybe) , ) # note the trailing comma, which is essential here.

So it was the comma.  Hmmmm

There is no reason why an Array can only have one item. But in order to make things generic, there needs to be a way to have more than one.

I have array's all the tme with only one element. Then add t them latter. Raku does not seem to care. So I am confused
3) what is the difference between "buttons" and "response"?
Both of these give two buttons:
      :buttons(Dismiss => 'Dismiss Test', :Response('Dismissed'))
This is simply raku. There are two ways to define a pair (a) String => SomeObject, (b) :String(SomeObject)
When you use => the key is autoquoted to make it a string.

I understand

4) why am I getting a weird response:
     popup = <Informative::Informing<86939520>>

Not at all weird, but highly informative :) . This is telling you that popup is an Informing Object instance from the Informative Module.

If you look at the text (which you can find in github - my p6/raku repositories are public), you will see how Informative is defined.

data.response = <Informative::Informing<86939696>.response>

how do I turn it into something useful to me?


5) What is popup suppose to show?
Say what?

$popup.show(


6) why is it not dismissing after 5 seconds?
I don't understand this. I am not prescient - I cannot see what is happening on your screen with your setup. It works fine on my computer.

It just sits there on my screen.  You example works though.


7) why is there no "show-countdown"?

There is! `:show-countdown` is named parameter to the method 'show', and an example is shown.

By default `:show-countdown` is True, so there is no need to set it if you want a countdown. If you dont want a count-down shown, then you need to set `:!show-countdown` , which in itself is a shortcut for `show-countdown(True)` . This was one of the examples.

I think I misunderstand what :show-countdown does. I was thinking the pop up would have a time showing remain seconds
to dismiss.


Hope the Module could be of some use.

Oh I love it.  It will get a lot of use!

:-)

Thank you!

-T

Reply via email to