Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Author Topic: Create a button by script !?!?  (Read 6213 times)

0 Members and 1 Guest are viewing this topic.

Endrit

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 62
    • View Profile
Create a button by script !?!?
« on: February 21, 2012, 05:59:53 PM »

Hi guys ,
I have a problem !
In a window i have a button and when i press this one i'd like that it create another button !
I have this code but it doesn't function ;

Code: WME Script
  1. on "button1" {
  2. var button2 = CreateButton("button2");
  3.  
  4. }
  5.  

please help me ! Thanks to all !
« Last Edit: February 23, 2012, 03:41:23 PM by Endrit »
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Create a button by script !?!?
« Reply #1 on: February 21, 2012, 09:12:39 PM »

so even if you do something like the following it doesn't work? Does the "Sanity check!" message display?

Code: WME Script
  1.  
  2. on "button1" {
  3.  
  4. Game.Msg("Sanity check!");
  5.  
  6. var button2 = this.CreateButton("button2");
  7. button2.X = this.Width * 0.5;
  8. button2.Y = this.Height * 0.5;
  9.  
  10. button2.Width = 200;
  11. button2.Height = 100;
  12.  
  13. button2.Text = "I am a button";
  14. button2.Visible = true;
  15.  
  16. }
  17.  
  18.  

Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Endrit

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 62
    • View Profile
Re: Create a button by script !?!?
« Reply #2 on: February 23, 2012, 03:40:45 PM »

so even if you do something like the following it doesn't work? Does the "Sanity check!" message display?

Code: WME Script
  1.  
  2. on "button1" {
  3.  
  4. Game.Msg("Sanity check!");
  5.  
  6. var button2 = this.CreateButton("button2");
  7. button2.X = this.Width * 0.5;
  8. button2.Y = this.Height * 0.5;
  9.  
  10. button2.Width = 200;
  11. button2.Height = 100;
  12.  
  13. button2.Text = "I am a button";
  14. button2.Visible = true;
  15.  
  16. }
  17.  
  18.  

Thank you !!! :)
I really didn't think to make it visible :| ! ::rock
Logged

Endrit

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 62
    • View Profile
Re: Create a button by script !?!?
« Reply #3 on: February 25, 2012, 07:54:44 PM »

so even if you do something like the following it doesn't work? Does the "Sanity check!" message display?

Code: WME Script
  1.  
  2. on "button1" {
  3.  
  4. Game.Msg("Sanity check!");
  5.  
  6. var button2 = this.CreateButton("button2");
  7. button2.X = this.Width * 0.5;
  8. button2.Y = this.Height * 0.5;
  9.  
  10. button2.Width = 200;
  11. button2.Height = 100;
  12.  
  13. button2.Text = "I am a button";
  14. button2.Visible = true;
  15.  
  16. }
  17.  
  18.  

well i'd like to delete it but it doesn't function  ::slug ::slug!
 the code is now :
Code: WME Script
  1.  
  2. on "button1" {
  3.  
  4. Game.Msg("Sanity check!");
  5.  
  6. var button2 = this.CreateButton("button2");
  7. button2.X = this.Width * 0.5;
  8. button2.Y = this.Height * 0.5;
  9.  
  10. button2.Width = 200;
  11. button2.Height = 100;
  12.  
  13. button2.Text = "I am a button";
  14. button2.Visible = true;
  15.  
  16. }
  17.  
  18. on "button2" {
  19.  
  20. Game.Msg("Sanity check!");
  21.  
  22. var delete = this.DeleteButton("buttno2");
  23.  
  24. }
  25.  
i added the game message to check it but nothing !
 ::slug ::slug ::slug ::slug ::slug ::slug ::slug
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Create a button by script !?!?
« Reply #4 on: February 25, 2012, 09:21:12 PM »

if this code is actual, you have a few problems:

var delete = this.DeleteButton("buttno2"); //note a typo (buttno)

I am not sure you can delete button by name, correct way is:

Code: WME Script
  1.  
  2. var btn = this.GetControl("button2");
  3. this.DeleteButton(btn);
  4.  
  5.  

 
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Create a button by script !?!?
« Reply #5 on: February 25, 2012, 10:24:49 PM »

Also when creating the button, set its ParentNotify property to true, so that it sends events to the window.

Code: WME Script
  1. button2.ParentNotify = true;
  2.  
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Endrit

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 62
    • View Profile
Re: Create a button by script !?!?
« Reply #6 on: February 25, 2012, 10:30:05 PM »

if this code is actual, you have a few problems:

var delete = this.DeleteButton("buttno2"); //note a typo (buttno)

I am not sure you can delete button by name, correct way is:

Code: WME Script
  1.  
  2. var btn = this.GetControl("button2");
  3. this.DeleteButton(btn);
  4.  
  5.  


In this way it function !
But I tried to to delete it by clicking on it the code is the next and it doesn't function :(  ::slug ::slug ::slug ::slug
(I know that I'm being boring but i need your help metamorphium ! Sorry :(



Code: WME Script
  1. var c_map= this.CreateButton ("Maps");
  2. c_map.Name = "Maps";
  3. c_map.X = 20 ;
  4. c_map.Y = 40 ;
  5. c_map.Width = 35;
  6. c_map.Height = 40 ;
  7. c_map.SetImage("interface\omega\Maps0001.png");
  8. c_map.SetHoverImage ("interface\omega\Maps0002.png") ;
  9. c_map.Visible = true ;
  10. var btn = this.GetControl("Maps");
  11.  
  12. on "Maps" {
  13. this.DeleteButton (btn);
  14. }
  15.  
  16.  
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Create a button by script !?!?
« Reply #7 on: February 26, 2012, 10:17:06 AM »

See my post above.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Endrit

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 62
    • View Profile
Re: Create a button by script !?!?
« Reply #8 on: February 26, 2012, 10:46:02 AM »

Thank  you Mnemonic !
Logged
 

Page created in 0.04 seconds with 24 queries.