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) { if (!resizeTimeout) {
resizeTimeout = setTimeout(function() { resizeTimeout = setTimeout(function() {
resizeTimeout = null; resizeTimeout = null;
actualResizeHandler(); resizeHandler();
}, 100); }, 100);
} }
} }
@ -145,6 +145,17 @@ function msgSet (m) {
if (debug) console.log ("Set", node, parts, value); 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) { function msgCall (m) {
const id = m.id; const id = m.id;
const node = getNode (id); const node = getNode (id);
@ -203,6 +214,9 @@ function processMessage (m) {
case "set": case "set":
msgSet (m); msgSet (m);
break; break;
case "setAttr":
msgSetAttr (m);
break;
case "call": case "call":
msgCall (m); msgCall (m);
break; break;

View File

@ -102,6 +102,16 @@ namespace Ooui
Style.PropertyChanged += HandleStylePropertyChanged; 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) void HandleStylePropertyChanged (object sender, PropertyChangedEventArgs e)
{ {
SendSet ("style." + Style.GetJsName (e.PropertyName), Style[e.PropertyName]); SendSet ("style." + Style.GetJsName (e.PropertyName), Style[e.PropertyName]);

View File

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

View File

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