Shoes in modern Ruby and Webview
This document outlines known incompatibilities between Scarpe and classic Shoes3 (the original _why implementation and its successors).
These widgets exist only in Shoes3 and have no Scarpe equivalent:
plot - Graphing/charting widgetterminal - Embedded terminal emulatorsystray - System tray iconspinner - Loading spinner widgetswitch - Toggle switch widget (use check instead)video - Video player (VLC-based in Shoes3)svghandle - SVG rendering (Scarpe uses image with SVG data URIs)Shoes. methods)Shoes.settings - Application preferencesShoes.monitor - Display/monitor detectionShoes.show_manual - Built-in manual viewer (stub only in Scarpe)RELEASE_* constants - Version/release infoshoesevent - Programmatic event creationevent block - Global event capture/replaydecoration - Window decoration controlcache - Asset caching systemmenu, menubar - Native OS menusShoes.appClassic Shoes allowed calling ask(), alert(), and other builtins at the top level without wrapping in Shoes.app:
# This works in classic Shoes, NOT in Scarpe
guess = ask "What's your name?"
alert "Hello, #{guess}!"
Scarpe requires Shoes.app because builtins need a WebView context:
# Scarpe-compatible version
Shoes.app do
guess = ask "What's your name?"
alert "Hello, #{guess}!"
end
Methods defined AFTER Shoes.app are not available inside the block:
# This will FAIL - to_radians doesn't exist when Shoes.app runs
Shoes.app do
angle = to_radians(45) # NoMethodError!
end
def to_radians(deg)
deg * Math::PI / 180
end
Solution: Define helper methods BEFORE Shoes.app:
# This WORKS
def to_radians(deg)
deg * Math::PI / 180
end
Shoes.app do
angle = to_radians(45) # Works!
end
In classic Shoes, widgets knew their position after layout. In Scarpe, self.left and self.top inside Widget#initialize return nil because browser layout hasn’t occurred yet.
class MyWidget < Shoes::Widget
def initialize
@x = self.left # nil in Scarpe, had value in classic Shoes
end
end
ask() Cancel Behaviorask() returned nil on cancelask() returns empty string "" on cancel (more predictable for string operations)Calling confirm(), ask(), or alert() before Shoes.app exists doesn’t work in Scarpe:
# Works in classic Shoes, fails in Scarpe
if confirm("Continue?")
Shoes.app { ... }
end
Some Shoes3 examples require gems that are dead or incompatible with modern Ruby:
Shoes.app - Don’t rely on top-level builtinsShoes.app - Method order matters in Rubycheck instead of switch - Similar functionalitysvghandle with image - SVG data URIs work wellask() cancel handling - Now returns "" not nilScarpe has excellent compatibility with core Shoes features:
stack, flow, backgroundrect, oval, line, arc, star, shape, maskpara, title, subtitle, tagline, caption, inscription, bannerspan, strong, em, link, code, ins, del, sub, supbutton, click, hover, leave, keypress, motionedit_line, edit_box, list_box, check, radioanimate, timer, everyalert, confirm, ask, ask_color, ask_open_file, ask_save_filefill, stroke, strokewidth, nofill, nostroke, rotateShoes::Widget subclassesurl and visitTurtle.draw / Turtle.start supportThe Hackety Hack samples are a good test suite - 9 of 12 run unmodified on Scarpe.