FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

0 terminated string of (*HJson.value).toString

 
Post new topic   Reply to topic     Forum Index -> flowerd
View previous topic :: View next topic  
Author Message
yidabu



Joined: 21 Apr 2007
Posts: 87

PostPosted: Sun Mar 30, 2008 2:17 am    Post subject: 0 terminated string of (*HJson.value).toString Reply with quote

here is a example:

Code:
        if( auto ele = rootElement.getId("textarea_id".dup) )
        {   auto str = (*ele.value).toString;         
             Trace.formatln("string {}", str);
        }



I use this trick to remove the null everywhere:

Code:
            if(str.length && str[$-1] is '\0')
            {
                str.length = str.length -1;
            }

_________________
D yuyan
Back to top
View user's profile Send private message
bobef



Joined: 05 Jun 2005
Posts: 269

PostPosted: Sun Mar 30, 2008 1:19 pm    Post subject: Reply with quote

Thanks. I will fix this in the next release. Also, you will no longer need to write (*ele.value).toString but ele.value.toString will be fine. By the way, why do you need .dup in here rootElement.getId("textarea_id".dup)?
Back to top
View user's profile Send private message
yidabu



Joined: 21 Apr 2007
Posts: 87

PostPosted: Sun Mar 30, 2008 4:48 pm    Post subject: Reply with quote

bobef wrote:
Thanks. I will fix this in the next release. Also, you will no longer need to write (*ele.value).toString but ele.value.toString will be fine. By the way, why do you need .dup in here rootElement.getId("textarea_id".dup)?


thx a lot!

I used a HWND to load two sourc.htm, I have not lucky to figured out some issues, e.g., click button a, but button b has been executed, so I tried add .dup to string, tried add sleep(seconds) before OnDomready .... to see the result.

subclass your HLayoutControl class for every HWND now, seems ok.
_________________
D yuyan
Back to top
View user's profile Send private message
bobef



Joined: 05 Jun 2005
Posts: 269

PostPosted: Mon Mar 31, 2008 12:54 am    Post subject: Reply with quote

For buttons you can do something like this:
Code:
myButton.handleEvent(delegate(HBehaviorEvent e)
{
  if(e.cmd==BUTTON_CLICK) {return true;//dome something}
  else return false;
});
Back to top
View user's profile Send private message
yidabu



Joined: 21 Apr 2007
Posts: 87

PostPosted: Mon Mar 31, 2008 5:31 am    Post subject: Reply with quote

bobef wrote:
For buttons you can do something like this:
Code:
myButton.handleEvent(delegate(HBehaviorEvent e)
{
  if(e.cmd==BUTTON_CLICK) {return true;//dome something}
  else return false;
});


is it possible one delegate to handle all button events?

Code:
buttons.handleEvent(delegate(HBehaviorEvent e)
{
  if(e.cmd==BUTTON_CLICK)
  {
     if(p.element["link"])
          //navigateTo(p.element["link"]);

     return true;//dome something
  }
  else return false;
});


to handle hundreds of elements event (e.g. tree view, every li is a link) manually, it's nightmare.
_________________
D yuyan
Back to top
View user's profile Send private message
bobef



Joined: 05 Jun 2005
Posts: 269

PostPosted: Mon Mar 31, 2008 11:31 am    Post subject: Reply with quote

Sure.

Code:
bool myDelegate(HBehaviorEvent p)
{
//dosomething
}

HElement[100] myelements;

foreach(m;myelements) m.handleEvent(&myDelegate);


Keep in mind that if you are using handleEvent you must keep a reference to the HElement somewhere, otherwise the GC could wipe out your event. If you are not keeping a reference you can use handleStatic instead of handleEvent. This way the handler will persist as long as underlaying HELEMENT is not destroyed by HTMLayout.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> flowerd All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group