1- use e_window_api:: { EWindow , WindowConfig , Card } ;
2-
3- /// Demonstrates anchor link functionality in e_window_api
4- ///
5- /// This example shows how to create cards with clickable anchor links
6- /// that can:
7- /// - Launch other e_window instances
8- /// - Open URLs in the default browser
9- /// - Execute system commands
10- /// - Display text-only anchors (non-clickable)
11- #[ tokio:: main]
12- async fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
13- println ! ( "Starting anchor links demo..." ) ;
14-
15- // Create a window to demonstrate anchor functionality
16- let config = WindowConfig :: new ( )
17- . title ( "Anchor Links Demo" )
18- . size ( 800 , 600 )
19- . position ( 200 , 200 ) ;
20-
21- let mut window = EWindow :: launch ( config) . await ?;
22-
23- // Create a card with various types of anchors
24- let main_card = Card :: new ( )
25- . window_title ( "Anchor Links Demo" )
26- . field ( "demo" , "anchor_links" )
27- . field ( "version" , "1.0" )
28- . card_title ( "🔗 e_window Anchor Links Demo" )
29- . header ( "Click the buttons below to test different anchor types" )
30- . caption ( "This demonstrates the anchor link functionality" )
31- . body_line ( "" )
32- . body_line ( "📋 Available anchor types:" )
33- . body_line ( "" )
34- . anchor ( "🪟 Launch another e_window" , "e_window --title \" Spawned Window!\" --width 400 --height 300 --x 100 --y 100" )
35- . body_line ( "" )
36- . anchor ( "🌐 Open Google in browser" , "https://www.google.com" )
37- . body_line ( "" )
38- . anchor ( "🧮 Open Calculator" , "calc.exe" )
39- . body_line ( "" )
40- . anchor ( "📂 Open File Explorer" , "explorer.exe" )
41- . body_line ( "" )
42- . anchor_text ( "📝 This is a text-only anchor (not clickable)" )
43- . body_line ( "" )
44- . body_line ( "💡 Tips:" )
45- . body_line ( "- URL anchors (http/https) open in your default browser" )
46- . body_line ( "- Command anchors execute system commands" )
47- . body_line ( "- e_window anchors can launch new windows with specific configs" )
48- . body_line ( "- Text-only anchors are for display purposes" ) ;
49-
50- window. show_card_with_auto_close ( main_card, 30 ) . await ?;
51-
52- println ! ( "Demo window launched! Try clicking the anchor buttons." ) ;
53- println ! ( "Window displays countdown timer automatically!" ) ;
54-
55- // Wait for auto-close (30 seconds)
56- tokio:: time:: sleep ( tokio:: time:: Duration :: from_secs ( 30 ) ) . await ;
57- println ! ( "Window auto-closed successfully!" ) ;
58-
59- window. close ( ) . await ?;
60- Ok ( ( ) )
61- }
1+ use e_window_api:: { Card , EWindow , WindowConfig } ;
2+
3+ /// Demonstrates anchor link functionality in e_window_api
4+ ///
5+ /// This example shows how to create cards with clickable anchor links
6+ /// that can:
7+ /// - Launch other e_window instances
8+ /// - Open URLs in the default browser
9+ /// - Execute system commands
10+ /// - Display text-only anchors (non-clickable)
11+ #[ tokio:: main]
12+ async fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
13+ println ! ( "Starting anchor links demo..." ) ;
14+
15+ // Create a window to demonstrate anchor functionality
16+ let config = WindowConfig :: new ( )
17+ . title ( "Anchor Links Demo" )
18+ . size ( 800 , 600 )
19+ . position ( 200 , 200 ) ;
20+
21+ let mut window = EWindow :: launch ( config) . await ?;
22+
23+ // Create a card with various types of anchors
24+ let main_card = Card :: new ( )
25+ . window_title ( "Anchor Links Demo" )
26+ . field ( "demo" , "anchor_links" )
27+ . field ( "version" , "1.0" )
28+ . card_title ( "🔗 e_window Anchor Links Demo" )
29+ . header ( "Click the buttons below to test different anchor types" )
30+ . caption ( "This demonstrates the anchor link functionality" )
31+ . body_line ( "" )
32+ . body_line ( "📋 Available anchor types:" )
33+ . body_line ( "" )
34+ . anchor (
35+ "🪟 Launch another e_window" ,
36+ "e_window --title \" Spawned Window!\" --width 400 --height 300 --x 100 --y 100" ,
37+ )
38+ . body_line ( "" )
39+ . anchor ( "🌐 Open Google in browser" , "https://www.google.com" )
40+ . body_line ( "" )
41+ . anchor ( "🧮 Open Calculator" , "calc.exe" )
42+ . body_line ( "" )
43+ . anchor ( "📂 Open File Explorer" , "explorer.exe" )
44+ . body_line ( "" )
45+ . anchor_text ( "📝 This is a text-only anchor (not clickable)" )
46+ . body_line ( "" )
47+ . body_line ( "💡 Tips:" )
48+ . body_line ( "- URL anchors (http/https) open in your default browser" )
49+ . body_line ( "- Command anchors execute system commands" )
50+ . body_line ( "- e_window anchors can launch new windows with specific configs" )
51+ . body_line ( "- Text-only anchors are for display purposes" ) ;
52+
53+ window. show_card_with_auto_close ( main_card, 30 ) . await ?;
54+
55+ println ! ( "Demo window launched! Try clicking the anchor buttons." ) ;
56+ println ! ( "Window displays countdown timer automatically!" ) ;
57+
58+ // Wait for auto-close (30 seconds)
59+ tokio:: time:: sleep ( tokio:: time:: Duration :: from_secs ( 30 ) ) . await ;
60+ println ! ( "Window auto-closed successfully!" ) ;
61+
62+ window. close ( ) . await ?;
63+ Ok ( ( ) )
64+ }
0 commit comments