IRC Log Viewer » #firebreath » 2012-08-31

IRC Nick Time (GMT-7) Message
beezboy 01:08 Hello everybody
again
I haven't any idea how use FB::JSAPIPtr for call JS methods
reichi 01:08 Invoke
is the magic word
just look at the wiki
there are examples!
beezboy 02:08 yes
But I have compilation errors
I put FB::JSAPIPtr ptr;
and ptr->Invoke("accept", FB::variant_list_of("hello world"));
reichi 02:08 wait
you need the jasapiptr to something that exists
not just randomly instantiate one ;)
and hmm
FB::JSObjectPtr js = m_host->getDOMElement()->getJSObject();
this way
e.g.
beezboy 02:08 Yes, this call directly JS methods
reichi 02:08 FB::variant item;
item = js->Invoke("getBoundingClientRect", FB::variant_list_of());
that's the way to go
usually
beezboy 02:08 But if I want to call MyPluginAPI method
reichi 02:08 why would you ever use invoke on that?
just call it
it's c++
invoke is for calling things on the javascript stack
you do not own
and have no direct acces to via c++
if your c++ class has a method "getSomethingFunny()"
just call
getSomethingFunny()
it doesn't matter if it's exposed to javascript, too, or not
beezboy 02:08 Ok, more clear
I start learning C++ some weeks ago... :)
reichi 02:08 aah
and you don't have much programming experience at all, right?
;)
you took a pretty complex topic for starting
nothing easier you can do? ;)
because for the whole npapi stuff one should bring quite solid knowledge about quite some things ;)
beezboy 02:08 I have some experience in developing, but this is the first more complex thing
reichi 02:08 ok
beezboy 02:08 Yes, I agree with you
reichi 02:08 i'll try to keep it simple
for everything you want to do in the c++ part
and where you "own" the code
you directly call c++
if you want to expose things to javascript
you use registerMethod, e.g.
beezboy 02:08 Yes. This part is OK ;)
For example, I have some fear because I need to call MyPluginAPI method, but this is an object that is in memory already
My first reaction is use new MyPluginApi...
But I think that I can create some problems
reichi 02:08 you cannot instantiate the Api class
never ever
that is one thing you don't touch
you just act within it
after the whole framwork did the rest for you
beezboy 02:08 Ok, perfect! :D
Some days ago, I comment use FB_JSAPI_EVENT
too
but, again, compilation erros
FireEvent function not found or something similar
reichi 02:08 probably you forgot the required imports
but hard to say without any code ;)
BEGIN_PLUGIN_EVENT_MAP()
EVENTTYPE_CASE(FB::MouseDownEvent, onMouseDown, FB::PluginWindow)
END_PLUGIN_EVENT_MAP()
should look like that
oh sorry
now i'm wrong ;)
FB_JSAPI_EVENT(PlayStateChange, 0, ());
that's it ;)
beezboy 02:08 My includes are the same that there are in MyPluginAPI, but in my class
I put more info... wait 1 sec
reichi 02:08 the compiler error may already help
but plase use a pastebot for it
beezboy 02:08 Ok
Give me 1 minut :D
reichi 02:08 but I'm still not sure if you really want to start with something so complex
(you totally want, but i think you shouldn't :/)
beezboy 02:08 It is not hobby... It's work :(
reichi 02:08 and you have nos upport?
there should be someone around you helping you out
beezboy 02:08 I work alone
Alone... with my c++ books...
This is some skeleton of problem: http://pastebin.com/RFFmsVdS
reichi 02:08 void Myclass::mymethod
in your cpp
attention, it's c++ ;)
you simply have no reference to you class
which makes your method a function
which obviously is not connected to MyClass
class Myclass
without .h
but maybe that's just a typo
Javascript Events should always start with an Uppercase Letter
that's the common naming convention
beezboy 02:08 Ok some lapsus, in my code is OK
reichi 02:08 well
hard to say
but something is wrong ;)
this usually works
beezboy 02:08 possible issue?
reichi 02:08 i don't know
did you use the class templates genereated by firebreath?
if not you really should
beezboy 02:08 This is class created by myself
reichi 02:08 copy the example
and make it fit
that's way better
and you do have this code in the correct class?
there's always two
the non-API one
beezboy 02:08 error: ‘FireEvent’ is not declared at this scope is referenced by FB_JSAPI_EVENT
reichi 02:08 yes
you either placed this in the wrong class
or forgot some include
beezboy 02:08 I try to fit...
reichi 02:08 or you didn't derive your class from FB::JSAPIAuto
which may also explain the issue
when you generate your project
you get an primitive class you can start with
and you can copy that one over and over
and refactor the name
that makes sure all the elementary stuff is there
i would really recommend you doing it that way
otherwise there's millions of traps you may run into
beezboy 02:08 well
reichi 02:08 theres just like one example method and one example event in it
beezboy 02:08 extending with : public FB::JSAPIAuto delete this error
reichi 02:08 ^^
sorry but i have to do some work now :/
i'm jsut a FB user ;)
beezboy 02:08 Ok dont worry another eror is coming xD
error: not call to ‘void MyClass::fire_eventcall(const string&)’ without object
reichi 02:08 check the examples
i really don't have more time :/
beezboy 02:08 Don't worry, thanks with your helpful
Helpful help :D
dash__ 03:08 anyone know if cross-browser context menus can be done using FireBreath?
beezboy 05:08 Hello again :d
how can I get the BrowserHost pointer?
reichi 05:08 in your API class
m_host
beezboy 05:08 Then I pass it to my object.