Slastraf Posted January 18, 2021 Share Posted January 18, 2021 Hello, i don thave much time to make this but here is a bug report about making a new window in U.A.K. Therefore I am posting the whole script I got, and will tell you where the important lines are. #include "pch.h" #include <iostream> #include <fstream> using namespace UltraEngine; string compileAndWrite(fstream& file, string& contentsOfWebsite); string compileAndExport(string& contents); bool RescaleUI(const Event& event, shared_ptr<Object> extra) { auto ui = dynamic_pointer_cast<Interface>(extra); ui->SetScale(float(event.data) / 100.0f); auto window = dynamic_pointer_cast<Window>(event.source); window->SetShape(event.position.x, event.position.y, event.size.x, event.size.y); return true; } int main(int argc, const char* argv[]) { fstream sourceFile; string contentsOfWebsite = ""; cout << "app starting..." << endl; auto displays = ListDisplays(); displays = ListDisplays(); auto win = CreateWindow("Slastraf Tool", 0, 0, 1000 /** displays[0]->scale*/, 600 /** displays[0]->scale*/, displays[0], WINDOW_HIDDEN | WINDOW_CENTER | WINDOW_TITLEBAR | WINDOW_RESIZABLE | WINDOW_DOUBLEBUFFERED); win->SetMinSize(600, 300); auto ui = CreateInterface(win); auto mainpanel = CreatePanel(0, 0, win->ClientSize().x, win->ClientSize().y, ui); mainpanel->SetAlignment(1, 1, 1, 1); auto mainmenu = CreateMenu("", mainpanel); int menuheight = mainmenu->GetSize().y; auto menu_file = CreateMenu("File", mainmenu); auto menu_new = CreateMenu("New", menu_file); auto newFileWindow = CreateWindow("Create New File", 0, 0, 420, 2 * 69, displays[0], WINDOW_HIDDEN | WINDOW_CENTER | WINDOW_TITLEBAR | WINDOW_RESIZABLE | WINDOW_DOUBLEBUFFERED); auto newFileUi = CreateInterface(newFileWindow); auto mainNewFilepanel = CreatePanel(0, 0, newFileWindow->ClientSize().x, newFileWindow->ClientSize().y, newFileUi); mainNewFilepanel->SetAlignment(1, 1, 1, 1); auto mainNewMenu = CreateMenu("", mainNewFilepanel); auto textfieldNew = CreateTextField(12, 10, newFileWindow->ClientSize().x*0.5, 32, mainNewMenu); textfieldNew->SetAlignment(1, 1, 1, 0); textfieldNew->SetText("untitled"); auto menu_saveTextNewFile = CreateButton("Save and close (doesnt work yet, just hide the window)", 12+(newFileWindow->ClientSize().x*0.5), 10, newFileWindow->ClientSize().x*0.23, 32, mainNewMenu); auto menu_open = CreateMenu("Open File...", menu_file); auto menu_save = CreateMenu("Save...", menu_file); auto menu_export = CreateMenu("Export", menu_file); ui->SetScale(displays[0]->scale); ListenEvent(EVENT_WINDOWDPICHANGED, win, RescaleUI, ui); win->Show(); win->Activate(); shared_ptr<TreeViewNode> dragnode, destnode; while (true) { auto event = WaitEvent(); switch (event.id) { case EVENT_WIDGETDROP: dragnode = event.source->As<TreeViewNode>(); if (dragnode) { destnode = event.extra->As<TreeViewNode>(); dragnode->Insert(destnode, event.data); } break; case EVENT_WIDGETSELECT: break; case EVENT_WIDGETACTION: if (event.source == menu_open) { wstring file = RequestFile(L"Open File"); sourceFile.open(file, ios::out); if (!sourceFile) { sourceFile.close(); } else { Notify("Opened file. Please export it later as .html to open it in browser."); } break; } if (event.source = menu_new) { newFileUi->SetScale(displays[0]->scale); ListenEvent(EVENT_WINDOWDPICHANGED, newFileWindow, RescaleUI, newFileUi); newFileWindow->Show(); newFileWindow->Activate(); break; } if (event.source == menu_save) { string errors = compileAndWrite(sourceFile, contentsOfWebsite); if (errors != "") { Notify(errors); } sourceFile.close(); break; } if (event.source == menu_saveTextNewFile) { sourceFile.open(textfieldNew->text, ios::out); newFileWindow->Close(); newFileWindow->Hide(); newFileWindow = nullptr; break; } if (event.source == menu_export) { string errors = compileAndExport(contentsOfWebsite); break; } break; case EVENT_WINDOWCLOSE: return 0; break; } } return 0; } //writes all changes to the file, does not export it string compileAndWrite(fstream& file, string& contentsOfWebsite) { /* if (contentsOfWebsite == "") { return "The app is empty, most likely an error."; } */ file << "hello thois isa a test"; return ""; } string compileAndExport(string& contents) { return ""; } I create a button at line 53 which is on a second window. This window is shown in line 107, so far so good but at line 124 it will not hide. I hope you can fix this issue soon. Regards Slastraf Quote Link to comment Share on other sites More sharing options...
Josh Posted January 19, 2021 Share Posted January 19, 2021 I set a breakpoint at line 124 and it is never being hit. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted January 19, 2021 Share Posted January 19, 2021 Here is the culprit: if (event.source = menu_new) { Should be: if (event.source == menu_new) { 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted January 19, 2021 Share Posted January 19, 2021 Doing this can prevent these type of mistakes in the future: const Event event = WaitEvent(); 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.