cristianotestai Posted July 20, 2011 Share Posted July 20, 2011 Hi Farshad, I have signed a runtime Ext event UniPanel as follows and work ok! UniPanel1.ClientEvents.ExtEvents.Values ['onmouseover']:=' onmouseover function (sender)' + '{Sender.body.applyStyles (' + QuotedStr ('background-color: # E5F2F7') + +');' 'FmHome.UniImage1.show ()' + '}'; What I need is for example to delete this event and a second time add again. Ex: 1) Event OnShow the MainForm I add the event. 2) I have a UniButton, and in the OnClick event, I need to eliminate the Ext Event to UniPanel. 3) In another UniButton, in the OnClick event, I need to add back the Ext Event or create another Ext Event to UniPanel. I'm trying so, but without success: To delete: UniSession.AddJS ('fmHome.UniPanel1.un ("mouseover", fmHome.UniPanel1.Onmouseover)'); or UniPanel1.ClientEvents.ExtEvents.Values ['onmouseover']:= ''; or UniPanel1.ClientEvents.ExtEvents.Clear; To add again: UniPanel1.ClientEvents.ExtEvents.Values ['onmouseover']:=' onmouseover function (sender)' + '{Sender.body.applyStyles (' + QuotedStr ('background-color: # E5F2F7') + +');' 'FmHome.UniImage1.show ()' + '}'; What i need to make in this case? Tks again.. Quote Link to comment Share on other sites More sharing options...
Tom Posted July 20, 2011 Share Posted July 20, 2011 Hi Cristiano, i had an similar challange with ext do() and un() functions a few days ago.. these two functions within ext are little bit tricky without an understandig of ext object model. however.. unigui does not send out a new "page" through out the client, when changing the ClientEvents on server side after the components have been created. consider an easier way to slove your problem: 1) place a tunilabel within your form (f.e. invisible) 2) set the labels' caption to 1 3) within the client event "onmouseover" you just using the lable for checking the components state: function mouseover(sender) { if ( parseInt(MyForm.MyInvisibleLable.text) == 1) /* do what ever you like to do ... changing background,etc */ } 4) in the client event "onclick" you can modify the lables value to change the behaviour of your component function onclick(sender) { MyForm.MyInvisibleLable.text = "2"; /* will turn of the mouseover event, because its not longer 1 */ } I hope you understood the logic of this "work around". Acutally we dont have the ability to extent existing components of unigui and so no possibility to enhance an ext object with additional properties (like .tag in delphi). But you can use a a label or what ever as an "internal storage" for your components' state. Using the client events with server-free logic for the user interface makes your application faster and smoother, because not every click oder mouseover event will generate a server request. I think thats for a delphi developer (and i have been one myself since 16 years) is a new perpective of thinking to develop an application wiche balance its logic between sever and client (so you ll get a real multi tier application). hope it helps. best regards! Tom Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted July 21, 2011 Administrators Share Posted July 21, 2011 You can't do it directly from Delphi. Currently it can be done only using JS code. To remove a previously defined event: UniSession.SendResponse('MainForm.UniButton1.un("click", MainForm.UniButton1.OnClick)'); To add it again: UniSession.SendResponse('MainForm.UniButton1.on("click", MainForm.UniButton1.OnClick)'); Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted July 21, 2011 Administrators Share Posted July 21, 2011 Hi Cristiano, i had an similar challange with ext do() and un() functions a few days ago.. these two functions within ext are little bit tricky without an understandig of ext object model. however.. unigui does not send out a new "page" through out the client, when changing the ClientEvents on server side after the components have been created. Yes, in uniGUI events are only sent when Form is created. consider an easier way to slove your problem: 1) place a tunilabel within your form (f.e. invisible) 2) set the labels' caption to 1 3) within the client event "onmouseover" you just using the lable for checking the components state: Actually, there is no need for an invisible label. Just declare a new property for the Ext JS objects. JavaScript allows you to dynamically add new properties to an existing object. function OnAfterCreate(sender) { sender.myProperty=false; } function onclick(sender) { if (sender.myProperty==true) { } } In general there is no need to dynamically add or remove events. The correct method is to develop proper internal mechanisms which will enable/disable client side events. 1 Quote Link to comment Share on other sites More sharing options...
cristianotestai Posted July 21, 2011 Author Share Posted July 21, 2011 Tks Farshad and May! Quote Link to comment Share on other sites More sharing options...
Tom Posted July 24, 2011 Share Posted July 24, 2011 Actually, there is no need for an invisible label. Just declare a new property for the Ext JS objects. JavaScript allows you to dynamically add new properties to an existing object. Thats it.. makes things easier;) Thanks Farshad for your helpful advise! Quote Link to comment Share on other sites More sharing options...
Mario Posted February 28, 2019 Share Posted February 28, 2019 I'm using the version uniGUI Trial 1.50.0.1482 and video i'm testing has 10 seconds. Thank's Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.