Quantcast
Channel: Terra Informatica Forums - Sciter
Viewing all 617 articles
Browse latest View live

Repeatable binding nested property (1 reply)

$
0
0
I tried simple repeatable from standard examples "samples/repeatable/simple/repeatable.htm" and changed JSON to have nested properties:

<textarea #json>[
  { product:"Apple", price: 0.95, nested: {price: 0.95, b: 2} },
  { product:"Orange", price: 0.75, nested: {price: 0.95, b: 2} },
  { product:"Pear", price: 1.25, nested: {price: 0.95, b: 2} },
];</textarea>

Repeater stops to work on nested properties :(

<ul #products repeatable>
<li><output|text(product) /> <output|currency(nested.price) /></li>
</ul>

"+plus" has the same behaviour - once you get nested data - it stops showing it.

How to bind nested properties in "repeater" and "+plus"?

Strange behaviour using cloned elements in tiscript (1 reply)

$
0
0
Hi Andrew,

looks like i got some error understanding handling of input values in tiscript correctly. I want to use the HTML below to copy values from some inputs and a dropdown to a cloned tr which contains inputs + dropdown of the same types. When i change some input or the dropdown at the top and then click the #cycle_add button it will insert "old" values into the table, for example when setting the number input to "2" it will set the value of the clone to whatever the number was before i changed it. On the second time clicking #cycle_add it works and sets the right values in the table (which match what is visible in the inputs and dropdown on top).

Strangely the time in <div #test> at bottom always reflects the current value from the input on top.

Any idea what is going on there?

<html>
  <head>
  <title></title>
<style>
	#cycle_del
	{
		prototype: DelButton;
	}
</style>
    <script type="text/tiscript">  
      $(#cycle_add).onClick = function()
      {
		var tbody = self.$(#cycles_body);
		
		var cstart = self.$(#cstart);
		var cend = self.$(#cend);
		var prizes = self.$(#prizes);
		var distribution = self.$(#distribution);
		
        var tr = self.$(#cycles_element_template);
		var n = tr.clone();
		
		tbody.append(n);
		
		var es = tr.$(#es);
		var ee = tr.$(#ee);
		var ed = tr.$(#ed);
		var enp = tr.$(#enp);
		
		es.value = cstart.value;
		ee.value = cend.value;
		enp.value = prizes.value;
		ed.value = distribution.value;
		
		n.style["visibility"] = "visible";

self.$(#test).text = cstart.value.toString();
      }
	  class DelButton: Behavior 
	  {
        function onClick() 
		{ 
			var tr = this.$p(tr);
			tr.detach();
		}
      }
    </script>
  </head>
<body>  

	
	Start <input #cstart type="time" name="time" value="now" /> 
	End <input #cend type="time" name="time" value="now" />
	# of prizes <input #prizes type="number" min=1 max=9999999 step=1 value=1/>
	Distribution
	<SELECT #distribution>
		<option dbid=1 selected>Random</option>
		<option dbid=2>Balanced</option>
	</SELECT>
	<BUTTON #cycle_add>Add</button>

	<table style="width:*;height:*">
		<thead>
			<tr>
				<th colspan=5>Cycles</th>
			</tr>
			<tr>
				<th>Start</TH>
				<th>End</TH>
				<th># of prizes</TH>
				<th>Distribution</TH>
				<th></th>
			</tr>
		</thead>
		<tbody #cycles_body>
			<tr #cycles_element_template style="visibility:collapse">
				<td><input #es type="time" name="time" /></td>
				<td><input #ee type="time" name="time" /></td>
				<td><widget #enp type="number" min=1 max=9999999 step=1/></td>
				<td>
					<SELECT #ed>
						<option dbid=1>Random</option>
						<option dbid=2>Balanced</option>
					</SELECT>
				</td>
				<td><button #cycle_del cdel>Delete</button></td>
			</tr>
		</tbody>
	</table>
<div #test></div>
</body>
</html>

Are cookies supported? (1 reply)

$
0
0
Does Sciter HTTP client engine supports cookies?

detect when a child gets focus (3 replies)

$
0
0
<div>
  <input />
  <input />
  <input />
  <input />
  <input />
  <input />
  <input />
  <input />
</div>
Given the parent div, how can I detect when one of its child get the focus (the GOT_FOCUS event)? I want the event handler attached to the div because the child are created dynamically..

select nothing (3 replies)

$
0
0
given a <input |text/> element which the user selected a part of the text, how do I programatically collapse the selection to nothing selected?

I tried the following but had no success..
<html>
<script type="text/tiscript">
	$(button).onClick = function() {
		stdout.println("collapse selection")
		$(input).selection.collapse(#toCaret);
	};
</script>

<body>
	<input value="first select a part of this text and then click the button bellow" />
	<br>
	<button>Select nothing</button>
</body>
</html>

Element.insert return type (1 reply)

$
0
0
make Element.insert() return the inserted element, and not true/false, the bool return is useless..

handle_event got 32769 (1 reply)

$
0
0
hi Andrew
i have a button with id "btnClose" and i want attch BUTTON_CLICK command in my c++ class.
bool CAvBaseDialog::handle_event(HELEMENT he, BEHAVIOR_EVENT_PARAMS& params)
{
	__super::handle_event(he, params);
	if (!m_htmlRoot)
	{
	    return false;
	}
                 //m_htmlRoot has initilized on "OnDocumentComplete"
	HELEMENT heMine = m_htmlRoot.get_element_by_id("btnClose");
	if (heMine == he && params.cmd == BUTTON_CLICK)
	{
	    return true; 
	}
	return false;
}

when i click the "btnClose" button, i first get an message 32769, and then a message 1(BUTTON_PRESS), and never got BUTTON_CLICK(0).
can you help me to resolve it?

first: params.cmd=32769, next is 1.

How can i found my old topics? (1 reply)

$
0
0
Hi Andrew, i have post many message in this forums, but if i search with my user name as key word, i just found 18 results.
How can i found all my post?

the value property (1 reply)

$
0
0
Hi. I'm working on a custom behavior (widget). Please have a look at the following code. Is there no way to set the 'value' property of the element without changing the element's text?

<html>
<head>
	<script type="text/tiscript">
	class MyBehavior : Behavior
	{
		property value(v)
		{
			get { return 0; }
			set { $(#msg).text += v + "|"; }
		}
		
		var i = 0;
		function attached()
		{
			this.onMouse = function( evt ) {
				if( evt.type == Event.MOUSE_DOWN )
					this.value = this.i++; // This works correctly and does not set the element's text.
			}
		}
	}
	
	// 1. Applying the behavior to the element this way doesn't seem to work,
	// so I have to apply it using css 'prototype' property.
	//$(#test).prototype = MyBehavior;
	
	// 2. The following line will change the text of the p element to "30" instead of
	// setting the 'value' property of the attached behavior.
	//$(#test).value = 30; // This causes the text of the element to change, rather than the 'value' property.
	</script>
	
	<style>
		.my-behavior {
			prototype: MyBehavior;
			text-decoration: underline;
		}
	</style>
</head>
<body>
	<p #test .my-behavior>Click to change value</p>
	<p #msg></p>
</body>
</html>

programatically set focus to plaintext (1 reply)

$
0
0
I want to programatically set focus to my plaintext element, so the user can start typing in it. Tried the following way but it did not work..
<html>
<head>

<style>
	div { behavior:plaintext; cursor: text; border: solid 1px; }
</style>
<script type="text/tiscript">
	$(button).onClick = function() {
		$(div).state.focus = true;
	}
</script>
	
</head>

<body>
	<div>
		lorem ipsum dolor sit ames
	</div>
	<button>Focus the div plaintext element</button>
</body>
</html>

Can we assign identifier(id) to our sciter element. (2 replies)

$
0
0
Hi,

I am new to Sciter development. I would like to know whether we can assign identifier(id) to our Sciter Element? Is that possible?

Sciter is totally new concept for me and I would appreciate if anybody would like to help me out with my small queries.

Also please let me know if we can import data from XML, JSON or files like these into our Sciter code.

Thanks and Regards,
Shreyas.

How to install and use the SDK. (1 reply)

$
0
0
Hi,

This is actually coming late from my side, but could you please guide me how install and use Sciter SDK.

I would like to start my development on Sciter with a small hello world program.

I have downloaded the SDK and unzipped the package.

Thanks and Regards,
Shreyas.

Render as overlay (no replies)

$
0
0
Hi Andrew,

I want to render html content as overlay over my own content. I'm using <style>html { background: transparent; }</style>. I found that Scilite is currently not ready. Fortunately I managed to render Sciter content using SciterRenderD2D(...) into IDXGISurface. Only problem with this approach is that Sciter always clears render target. For that reason I need to render in two step - in first step render html into one surface and then compose it over destination surface. Is there any way how to tell Sciter not to clear render target?

Thank you

Martin

EXC_BAD_ACCESS on SCITER_VALUE call_function(LPCSTR name, SCITER_VALUE arg0 ) (1 reply)

$
0
0
I'm learning Sciter by adding GUI to multithread download library.

I've added a simple timer to standard SDK osx-demo:
inline void timer_start(std::function<void(void)> func, unsigned int interval)
{
    std::thread([func, interval]() {
        while (true)
        {
            func();
            std::this_thread::sleep_for(std::chrono::milliseconds(interval));
        }
    }).detach();
}

And synchronised notifications queue:

// synchronised queue template
template<typename T>
class SynchronizedQueue {
public:
    SynchronizedQueue() {}
    ~SynchronizedQueue() {}
    void push(std::unique_ptr<T>&& t)
    {
        std::lock_guard<std::mutex> l(m_);
        q_.push(std::move(t));
    }
    std::unique_ptr<T> pop()
    {
        std::lock_guard<std::mutex> l(m_);
        std::unique_ptr<T> t = std::move(q_.front());
        q_.pop();
        return t;
    }
    bool empty()
    {
        std::lock_guard<std::mutex> l(m_);
        return q_.empty();
    }
private:
    std::queue<std::unique_ptr<T> > q_;
    std::mutex m_;
    
};

// abstract notification
struct Notification {
    virtual ~Notification() {};
    virtual void notify(window& wnd) = 0;
};

// concrete notification
struct StatusNotification : public Notification {
    virtual void notify(window& wnd)
    {
        Json::Value jsonRoot;
        // make json here....
      
        auto std_string = jsonRoot.toStyledString();
        auto sciter_string = std_to_sciter_str(std_string);
        
        // such lock doesn't help here...
        //std::lock_guard<std::mutex> l1(wnd.m_);

         wnd.call_function("updateGui", sciter_string);
    }
};

using NotifyQueue = SynchronizedQueue<Notification>;

NotifyQueue notifyq_;


And call it in window constructor like:
auto notify_gui_functor = [&]() 
{
    while(!notifyq_.empty()) {
        std::unique_ptr<Notification> nt = notifyq_.pop();
        nt->notify(*this);
    }
};
timer_start(notify_gui_functor, 1000);


updateGui is defined as:
function updateGui(data) {
	var jsonData = parseData(data);
	var downloadsTable = $( div#downloads ); // it's div, not sure how to clear table's TRs before adding them again on a new GUI update
	downloadsTable.clear();
	for (var d in jsonData.downloads) {
		downloadsTable.$append ( <div>Cell {d.url} {d.statusDownloadSpeed}B/s {d.statusCompletedLength}/{d.statusTotalLength}</div> );
	};
}

Everything runs fine for a while (5-10 minutes) and then EXC_BAD_ACCESS happen. I can't figure if it's because of my code or if it's in Sciter internals.

Here are exception description screenshots (not sure how to copy/paste all text data in a right format):
[monosnap.com]
[monosnap.com]
[monosnap.com]

Any idea what is the reason of the error and how to avoid it?

Thanks a lot!

How to define a common color. (1 reply)

$
0
0
I have many html element with a same color #fdfdfd.
And how can I define a common value to use in any element just like:
#define MyColor #fdfdfd
div.myDiv
{
color:MyColor;
}
button.myBuuton
{
color:MyColor;
}

Decorators in Sciter (1 reply)

$
0
0
Hi,

Could you please explain me what exactly is the concept of Decorators with a small example.

Thanks and Regards,
Shreyas.

produzing valid JSON for PHP json_decode() (1 reply)

$
0
0
I want to interop TIScript with my php server side backend, and I am using String.printf("%v", myObject) to produce JSON data, problem is, the JSON string produced by TIScript is in an invalid format, not recognized by PHP json_decode...

I get the following json string:
{action:"edit_task",tid:"MDEzOTkzMDI4MDM4NjgwODU1NTE6MDoxMzI1ODE1OTIy",title:"whatever"}
notice that keys don't have surrounding quotation marks, that is the problem...

how to set align center.in vertical? (1 reply)

$
0
0
How can I center button text in vertical?
The code below can`t work, please test it in sciter.exe
<html>
<head>
    <style>
        button.myButton
        {
            width:300;
            height:200;
            text-align:center;
            vertical-align:middle;
        }
    </style>
</head>
<body>
    <button class="myButton">Want vertical center align</button>
</body>
</html>

i know padding works, but there should be a better way.

Sciter window creation. (1 reply)

$
0
0
Hi,

I was refering the following link:

Basic Sciter window creation

First thing here that I would like to say is, I was not able to understand piece of code from Method B.
Also there are these keywords like:

SC_LOAD_DATA notification

CreateWindow( SciterClassNameT(), ... )
SciterProcND()

SciterLoadFile();
SciterLoadHtml();

and a lot many other keywords on this page.

Could you please tell me where can I find reference to all these words, so that I could understand the code. I appologise if I am asking for a very basic concepts, but I need to understand these concepts.

Thanks and Regards,
Shreyas.

Select element by ID from variable (1 reply)

$
0
0
I have a select tag with
<option id="aaa">something</option>

When the option is called:
var excistingOption = $( #aaa );
It is found.

When it is called:
var selector = "#"+"aaa";
var excistingOption = $( selector );
It's not found.

Why the second option doesn't work? How to select elements by selectors from variables (IDs / Class names) ?
Viewing all 617 articles
Browse latest View live