First application


#1

I tried to fiddle around to create my first application running on this web desktop.
Although my code is litterally the same as “About OS.js” with just the difference in class’ name, it doesnt work: all it shows was only a blank window, nothing else, even the title “OS.js”.
Do you have any suggestion?


#2

Can you share your code ?


#3

From main.js. Litterally the same, except the name of class.

const Window = OSjs.require('core/window');
const Application = OSjs.require('core/application');

class ApplicationHelloWindow extends Window {
  constructor(app, metadata) {
    super('ApplicationHelloWindow', {
      icon: metadata.icon,
      title: metadata.name,
      gravity: 'center',
      allow_resize: true,
      allow_maximize: true,
      width: 500,
      height: 500,
      min_width: 320,
      min_height: 320
    }, app);
  }

  init(wm, app) {
    const root = super.init(...arguments);

    this._render('HelloWindow', require('osjs-scheme-loader!scheme.html'));

    return root;
  }
}

class ApplicationHello extends Application {
  constructor(args, metadata) {
    super('ApplicationHello', args, metadata);
  }

  init(settings, metadata) {
    super.init(...arguments);
    this._addWindow(new ApplicationHelloWindow(this, metadata));
  }
}

OSjs.Applications.ApplicationHello = ApplicationHello;

#4

Perhaps i figured out the reason: the data-id of application-window is still “AboutWindow”, which probably make the content not showing.


#5

Did you update the metadata.json file ?