Closed dredknight closed 8 years ago
I'm not that skilled about this so I could be wrong, but I think Shoes.widget class is there for creating your own widget (image acting as /button in this case). Subclass it and add methods/vars for what ever state variables you need for your buttons that you need to call from the main Shoes app.
Nooooo. Create a stack with an image inside, make sure you save the image object in a @variable also, and add a click event on the stack that will replace the image using its variable.
Or what @BackOrder said! Nice to hear from you.
You might want to explore sub-classing image. It might work if you just want to add a 'path' variable. Overriding draw() and initialize() could be a problem. Or not.
Or what @BackOrder said! Nice to hear from you.
Still so busy but I'm following the issue tracker.
You might want to explore sub-classing image. It might work if you just want to add a 'path' variable. Overriding draw() and initialize() could be a problem. Or not.
It's just too complicated for absolutely no reason. In Numinoes, I preload all images, define a click event on stacks, flip through images in an array.
If I remember correctly, @dredknight's app draws his image buttons in a circle and he implements tool-tip like enter/leave for each of them so he's already well past the boundaries of 'simple' and into the edges of what Shoes can do. I don't go there myself.
It's just too complicated for absolutely no reason
My personal preference is to find a simple way with the least eye-candy. But, if someone want the most eye-candy (and pain) we should help them if we can.
My personal preference is to find a simple way with the least eye-candy. But, if someone want the most eye-candy (and pain) we should help them if we can.
Thanks a lot for the support I will check the advices you all gave me and let you know where the muse hit me!
Alright I got something like this.
def set_button_up button, klas, hero
if hero<CLASSES[klas]["heroes"].length-1 then
hero+=1
@hero_box.clear { image "pics/heroes/#{CLASSES["#{klas}"]["heroes"][hero]}.png", width: 60 }
button.path = "pics/buttons/pushed.png"
set_skillwheel klas, hero
timer(0.1) { button.path = "pics/buttons/normal.png" }
end
end
@right_button = image "pics/buttons/normal.png", left: 385, top: 327
@right_button.click do
set_button_up @right_button, @ch_class, @ch_hero
end
But I stumbled on a wierd issue. as you can see I pass a variable called @ch_hero that I increase with each click. Unfortunately when it is increased inside the module (hero var) it is not saved in the oringal var (@ch_hero). Is there anyway I can returnthe change from hero to @ch_hero or I better do this outside the module?
def set_button_down button, klas, hero
unless hero==0 then
hero-=1
@hero_box.clear { image "pics/heroes/#{CLASSES[klas]["heroes"][hero]}.png", width: 60 }
button.path = "pics/buttons/pushed.png"
set_skillwheel klas, hero
timer(0.1) { button.path = "pics/buttons/normal.png" }
end
return hero
end
@left_button.click do
@ch_hero=set_button_down @left_button, @ch_class, @ch_hero
end
Done!
P.S. Unfortunately those image changes inside does not work as button.path does not transfer the change to @left_button but I will live with that ;)
Alright everybody I am getting the hang out Shoes better and better every day :) Unfortunately I stumbled upon something... actually it is very stupid I just dont know how to approach it.
I got an image and when I click it I want to change that image, it is very simple here is an example.
But I want many visually dynamic buttons so I put the code in a module. Then I do
the module itself is this
My question is how to change the PATH of the image from the inside when the image is not assigned to any variable?