classdef app_3_5_1 < matlab.apps.AppBase

  % Properties that correspond to app components
  properties (Access = public)
    UIFigure      matlab.ui.Figure
    ASCIILabel    matlab.ui.control.Label
    TextLabel     matlab.ui.control.Label
    ZeichenLabel  matlab.ui.control.Label
  end

  % Callbacks that handle component events
  methods (Access = private)

    % Code that executes after component creation
    function startupFcn(app)
      
    end

    % Key press function: UIFigure
    function UIFigureKeyPress(app, event)
      key = event.Key;
      app.TextLabel.Text = key;
      key1 = key(1);
      value = int32(key1);
      app.ASCIILabel.Text = dec2hex(value);
    end
  end

  % Component initialization
  methods (Access = private)

    % Create UIFigure and components
    function createComponents(app)

      % Create UIFigure and hide until all components are created
      app.UIFigure = uifigure('Visible', 'off');
      app.UIFigure.Position = [100 100 317 80];
      app.UIFigure.Name = 'MATLAB App';
      app.UIFigure.KeyPressFcn = createCallbackFcn(app, @UIFigureKeyPress, true);

      % Create ZeichenLabel
      app.ZeichenLabel = uilabel(app.UIFigure);
      app.ZeichenLabel.Position = [35 33 51 22];
      app.ZeichenLabel.Text = 'Zeichen:';

      % Create TextLabel
      app.TextLabel = uilabel(app.UIFigure);
      app.TextLabel.Position = [122 33 52 22];
      app.TextLabel.Text = 'Text';

      % Create ASCIILabel
      app.ASCIILabel = uilabel(app.UIFigure);
      app.ASCIILabel.Position = [213 33 48 22];
      app.ASCIILabel.Text = 'ASCII';

      % Show the figure after all components are created
      app.UIFigure.Visible = 'on';
    end
  end

  % App creation and deletion
  methods (Access = public)

    % Construct app
    function app = app_3_5_1

      % Create UIFigure and components
      createComponents(app)

      % Register the app with App Designer
      registerApp(app, app.UIFigure)

      % Execute the startup function
      runStartupFcn(app, @startupFcn)

      if nargout == 0
        clear app
      end
    end

    % Code that executes before app deletion
    function delete(app)

      % Delete UIFigure when app is deleted
      delete(app.UIFigure)
    end
  end
end