Add SetAttribute to Element

This commit is contained in:
Frank A. Krueger 2017-11-26 09:28:06 -08:00
parent 786343a8ae
commit ab546d0e28
5 changed files with 43 additions and 1 deletions

View File

@ -0,0 +1,10 @@
using System;
namespace Ooui.Forms.Renderers
{
public class ActivityIndicatorRenderer
{
public ActivityIndicatorRenderer ()
{
}
}
}

View File

@ -84,7 +84,7 @@ function ooui (rootElementPath) {
if (!resizeTimeout) {
resizeTimeout = setTimeout(function() {
resizeTimeout = null;
actualResizeHandler();
resizeHandler();
}, 100);
}
}
@ -145,6 +145,17 @@ function msgSet (m) {
if (debug) console.log ("Set", node, parts, value);
}
function msgSetAttr (m) {
const id = m.id;
const node = getNode (id);
if (!node) {
console.error ("Unknown node id", m);
return;
}
node.setAttribute(m.k, m.v);
if (debug) console.log ("SetAttr", node, m.k, m.v);
}
function msgCall (m) {
const id = m.id;
const node = getNode (id);
@ -203,6 +214,9 @@ function processMessage (m) {
case "set":
msgSet (m);
break;
case "setAttr":
msgSetAttr (m);
break;
case "call":
msgCall (m);
break;

View File

@ -102,6 +102,16 @@ namespace Ooui
Style.PropertyChanged += HandleStylePropertyChanged;
}
public void SetAttribute (string attributeName, string value)
{
Send (new Message {
MessageType = MessageType.SetAttribute,
TargetId = Id,
Key = attributeName,
Value = value,
});
}
void HandleStylePropertyChanged (object sender, PropertyChangedEventArgs e)
{
SendSet ("style." + Style.GetJsName (e.PropertyName), Style[e.PropertyName]);

View File

@ -163,6 +163,12 @@ namespace Ooui
state.Add (message);
});
break;
case MessageType.SetAttribute:
UpdateStateMessages (state => {
state.RemoveAll (x => x.MessageType == MessageType.SetAttribute && x.Key == message.Key);
state.Add (message);
});
break;
case MessageType.Listen:
AddStateMessage (message);
break;

View File

@ -46,6 +46,8 @@ namespace Ooui
Create,
[EnumMember(Value = "set")]
Set,
[EnumMember (Value = "setAttr")]
SetAttribute,
[EnumMember(Value = "call")]
Call,
[EnumMember(Value = "listen")]