Scripting Image Buttons

Post a reply

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Scripting Image Buttons

Re: Scripting Image Buttons

by rovingcowboy » Mon Aug 02, 2010 8:38 am

well the album art view with details is shown in the listview area when you click the button to see it.
the no album art images used in there have to be 100 x 100 as far as i know because i tried bigger ones and they did not work.

:D

Re: Scripting Image Buttons

by johnw3600 » Mon Aug 02, 2010 3:52 am

Thank for all the input.

Zvezdan, I had previously set just one RegisterEvent (not four) per ActiveX panel, but I then found...
id = ax2.Interf.document.activeElement.ID
...produced a blank ID.
But I was being stupid! :oops: I had given each Image an ID but not the image's <DIV> wrapper, so of course I was drawing a blank!
Now that works fine because I don't bother giving the image an ID just the <DIV>!
BTW Later I'll test whether indeed the image can be the ActiveElement if there is no <DIV> wrapper.

Keith, the fixed images I was a banging on about are in the Album Art view of the Main album/track window, and there the fixed size is much nearer 150px than 100 (and maybe more than that)!

Thanks again,
John

Re: Scripting Image Buttons

by rovingcowboy » Fri Jul 30, 2010 6:40 pm

oh i never seen that pop up list. it must be triggered by the mouse over but it might be the tool balloon that pops up.?

100 pixels is smaller then the icons in win7 or vista, both were made to be 128 x 128 at max size. xp can use those but if made for xp and vista they don't seem to be able to get as big as in win 7 for some reason.

maybe doing the 100 pixels size was also done so it will be uniform size in all the versions of windows. i know it can take up room on the screen when you have the tree and a lirycs window or album art window open too.
leaving very little for the listview area.
even more so when you are on a small screen res..

but the no album art image for use in the detailed view is controled by an image in the icons folder in the skins msz file.
maybe you can work with that direction some how? but it has to be 100 x 100 pixels. but you might be able to write a script that takes that image and vectors it down or up in size to show it in the album art with details view?

:-?

Re: Scripting Image Buttons

by johnw3600 » Fri Jul 30, 2010 10:21 am

Hmm, I think I will make a list of items that ought to come under Skin control (with a default in the program to keep old skins happy), and that's one of them. I go as far as to say that it seems amazingly silly that this is not already the case! :(

The 'Pop-up Track Information Display' which arrives with the MouseOver or OnClick event fired from the AlbumArt in the Track Window.

Re: Scripting Image Buttons

by rovingcowboy » Fri Jul 30, 2010 4:13 am

no album art view size is set by program. and they set it to 100 pixels.

what popup track list?

Re: Scripting Image Buttons

by johnw3600 » Thu Jul 29, 2010 7:45 am

Will do. Thanks.

BTW Is there anyway in MM where you can reduce the size of the Album Art as shown in the AlbumArt view of the Track Window. I need to see more albums at a time in my 'Jukebox'
I have looked in both the ini and 'theme' files of MM-Ultimate as well as all the options in MM and I can't find it anywhere!
Can I also remove the pop-up track list?

Cheers.

Re: Scripting Image Buttons

by ZvezdanD » Thu Jul 29, 2010 7:18 am

johnw3600 wrote:ax1.Interf.document.activeElement.ID replies with an empty string!
This is because you have registered an event to a particular element of the Web page:
Script.RegisterEvent ax1.Interf.document.getElementByID(cap(i)), "OnClick", click

You need to register an event to the container document:
Script.RegisterEvent ax1.Interf.document, "OnClick", click

Please, take a look at Magic Nodes or RegExp Find and Replace source code. Both of them have Export/Import dialog box which contains Web browser control with an array of "buttons" in the # column and only one event handler subroutine for all of them.

Re: Scripting Image Buttons

by johnw3600 » Thu Jul 29, 2010 6:33 am

Thanks Zvezdan,

I did post a reply to this but it got lost in the ether when the MediaMonkey site got lost for a while!

ax1.Interf.document.activeElement.ID replies with an empty string!I suspect that this is because an image object doesn't go 'Active' even though it does fire the OnClick event! So something else is needed.

I tried innumerable variations on window.event.srcElement.tagName with no joy either.

For the moment I have 4 OnClick handlers (like ClickHandler_1 etc) each on which calls ClickHandler(n) immediately, so the code block only has to appear once. This works, but is not a really neat solution.

Since Script.RegisterEvent logs the event handler against the caller element in the panel, it must be possible to read which element threw the event, but I don't see how!
Or is this a limitation on VBScript? (its obviously not a MM issue)

Or, can you set up a value in Script.RegisterEvent to be parsed (not passed) as a parameter when the event fires? I already know you can't register a handler as: ClickHandler("this_one") !!!

Other than this issue of code compactness (which is what the above is really all about), I now have my Big Buttons working fine, with four of them taking you to MagicNode folders in the Tree, and four more sending the selected album tracks to each of said folders, by updating the Custom1 field in the SongList (called Source in this instance).

This works very well with a Touch Screen, when perpetually typing into the required field is tedious!
In short, you can categorize an album according to its 'Source' as follow...
One click on the 'Unknown' Source button to open that node in the Tree,
One click on the album art for an album in the TrackWindow display, and
One click on the 'SendtoStudio' button to catagorize this album as 'Studio' in the Custom1 (Source) field!
I would happily publish this in the Wiki, but I would rather sort the Handler issue (above) out first, as currently I have 8 handlers when 2 would do!

Regards,
John

Re: Scripting Image Buttons

by johnw3600 » Wed Jul 28, 2010 8:09 am

Thanks Zvezdan.

But in the case of using an Image object that simply has an OnClick event handler, perhaps there is no sense in which the image becomes 'active' so...

ax1.Interf.document.activeElement.id

is null.

It must be possible to identify the caller from within the Handler function. VBScripting knows which of four Handlers to use, so it must have a Caller id associated with that Handler, that should be readily identifiable within the handler routine.

So, for the time being, I have 4 event handlers ClickHandler_1 (etc) which immediately call a single routine ClickHandler(n) with the appropriate parameter. But is there a way of registering the event handler with a given parameter to parse???

[Edit: I've removed some rubbish I wrote here about not being able to set CurrentNode = unknownNode...
I just hadn't spotted a logic error!!]

Regards,
John

Re: Scripting Image Buttons

by ZvezdanD » Tue Jul 27, 2010 3:43 pm

johnw3600 wrote:Q: How do I indentify the Sender of an OnClick event?
All four ClickHandler routines could be one, so long as I know the 'id' of the image object.
I suppose that you need something like this:

Code: Select all

Select Case ax1.Interf.document.activeElement.ID
Case cap(1)
...
Case cap(2)
...
End Select

Re: Scripting Image Buttons

by johnw3600 » Tue Jul 27, 2010 1:11 pm

Woh-hay!!!! :D :D :D

I now have my line of four lovely bright shiny image buttons, courtesy of ActiveX. Thanks Zvezdan, for forcing me to go there! These buttons aren't 'button objects' at all, they are just 4 HTML 'images' with OnClick events registered to each, all sitting in an ActiveX web browser object, which itself is in an oridinary vb panel.

They work beautifully, calling back to the vbscript on click.
I'm particularly pleased with...

Code: Select all

 html = ""
  for i = 1 to 4
  	style = "style='border:1px;width:48px;height:36px'"
  	html = html & "<img id='" & cap(i) & "' src='" & path & src(i) & "' " & style & " alt='" & cap(i) & "'>"
  next
  ax1.Interf.document.body.innerHTML = html
  for i = 1 to 4
    click = "ClickHandler_" & cap(i) 
    Script.RegisterEvent ax1.Interf.document.getElementByID(cap(i)), "OnClick", click
  next
[/color]
[Obviously the 'cap' and 'src' arrays and the ax1 object were defined higher up]

Later I will space the objects as I wish, with a table I expect so they float better if the dockable panel is stretched.

But I still have one question (aside from agreeing that you can do what the heck you like in Delphi so long as you accept that objects like TButton are a bit plain out-of-the-box)...

Q: How do I indentify the Sender of an OnClick event?
All four ClickHandler routines could be one, so long as I know the 'id' of the image object.

Thanks. John

Re: Scripting Image Buttons

by ZvezdanD » Tue Jul 27, 2010 7:10 am

Peke wrote:I guess I was not sure how to understand http://www.ventismedia.com/mantis/view.php?id=6336 but now when you mentioned it along with http://www.mediamonkey.com/wiki/index.php/SDBUIButton looks more clear.

Can you write me a PM so that we can see how to make framework for it as Delphi itself do not have Picture button object that can be used but BitButton without caption and Icon can be possibly used to represent button.
You are joking about Delphi lack of buttons with pictures, aren't you? I could send you my Delphi sources with a bunch of buttons with pictures. MediaMonkey itself has buttons with pictures in many places, e.g. up, down and delete buttons beneath of Options > Library > Filters & View or several buttons in the Track Properties dialog box. We don't need anything more then that, we need just same buttons as MediMonkey has.

By the way, here is a part of my old related message: Very serious problems with some scripting functions by ZvezdanD on Sun Dec 28, 2008 1:43 pm
"Listbox and Dropdown controls could have a property to assign icon/picture to every item in the list (something like Owner Draw Combo and List box controls in some languages). Buttons also could have a property to assign a icon/picture to them, with a possibility to decide if it should be displayed together with the caption or without it, and with the property to specify a relative position to caption - e.g. left to caption or above the caption."

Re: Scripting Image Buttons

by johnw3600 » Tue Jul 27, 2010 5:23 am

Thanks Zvezdan,

I simply had not grasped the import of a statement like:
Whether and how these skin objects are used totally depends on the implementation of the MediaMonkey Theme Engine
in the wiki under Theme Editor!

And Peke now I know you're coming from Delphi, I can see why buttons don't have an accessible Image property; at least TBitBtn objects have an accessible Glyph as well as Caption (either of which are then optional).

Ho Hum, It is ActiveX for now then!

John

Re: Scripting Image Buttons

by Peke » Mon Jul 26, 2010 9:24 pm

Zvezdan you are right. No image Button.

I guess I was not sure how to understand http://www.ventismedia.com/mantis/view.php?id=6336 but now when you mentioned it along with http://www.mediamonkey.com/wiki/index.php/SDBUIButton looks more clear.

Can you write me a PM so that we can see how to make framework for it as Delphi itself do not have Picture button object that can be used but BitButton without caption and Icon can be possibly used to represent button.

Re: Scripting Image Buttons

by ZvezdanD » Mon Jul 26, 2010 2:26 pm

johnw3600 wrote:Otherwise how could you make a player interface that works???

Or are we saying that the only objects recognised in such scripts are those predefined in MM
Forget about skinning, don't waste your time with it, that is the dead end. Buttons from the Player has nothing in common with the buttons from the scripts. MM API has just one button object that could be used in dockable panels: http://www.mediamonkey.com/wiki/index.php/SDBUIButton and that object doesn't support Image property.

Top